Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
HPWebdeveloper committed Jan 13, 2024
1 parent 7f24ec2 commit 356afde
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 80 deletions.
20 changes: 2 additions & 18 deletions src/Interfaces/WalletOperations.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,23 @@ interface WalletOperations
{
/**
* Get User's Wallet Balance
*
* @return int|float
*/
public function getWalletBalanceAttribute(): int|float;

/**
* Get the balance of a specific wallet type.
*
*
* @param string $walletType
*
* @return float|int
*/
public function getWalletBalanceByType(string $walletType): float|int;

/**
* Check if User's wallet balance is more than given value
*
* @param int|float $value
*
* @return bool
*/
public function hasSufficientBalance(int|float $value): bool;

/**
* Pay the order value from the user's wallets.
*
* @param int|float $orderValue
* @param ?string $notes
* @param ?string $notes
*
* @throws \HPWebdeveloper\LaravelPayPocket\Exceptions\InsufficientBalanceException
*/
Expand All @@ -43,11 +31,7 @@ public function pay(int|float $orderValue, ?string $notes = null): void;
/**
* Deposit an amount to the user's wallet of a specific type.
*
* @param string $type
* @param int|float $amount
* @param ?string $notes
*
* @return bool
* @param ?string $notes
*/
public function deposit(string $type, int|float $amount, ?string $notes = null): bool;
}
25 changes: 3 additions & 22 deletions src/Services/PocketServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ class PocketServices
/**
* Deposit an amount to the user's wallet of a specific type.
*
* @param \Illuminate\Database\Eloquent\Model $user
* @param string $type
* @param int|float $amount
* @param ?string $notes
*
* @return bool
* @param ?string $notes
*/
public function deposit(Model $user, string $type, int|float $amount, ?string $notes = null): bool
{
Expand All @@ -24,11 +19,8 @@ public function deposit(Model $user, string $type, int|float $amount, ?string $n
/**
* Pay the order value from the user's wallets.
*
* @param \Illuminate\Database\Eloquent\Model $user
* @param int|float $orderValue
* @param ?string $notes
* @param ?string $notes
*
* @return void
* @throws \HPWebdeveloper\LaravelPayPocket\Exceptions\InsufficientBalanceException
*/
public function pay(Model $user, int|float $orderValue, ?string $notes = null): void
Expand All @@ -38,11 +30,6 @@ public function pay(Model $user, int|float $orderValue, ?string $notes = null):

/**
* Get the balance of the user.
*
*
* @param \Illuminate\Database\Eloquent\Model $user
*
* @return float|int
*/
public function checkBalance(Model $user): int|float
{
Expand All @@ -51,15 +38,9 @@ public function checkBalance(Model $user): int|float

/**
* Get the balance of a specific wallet type.
*
*
* @param \Illuminate\Database\Eloquent\Model $user
* @param string $type
*
* @return float|int
*/
public function walletBalanceByType(Model $user, string $type): float|int
{
return $user->getWalletBalanceByType($type);

Check failure on line 44 in src/Services/PocketServices.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined method Illuminate\Database\Eloquent\Model::getWalletBalanceByType().
}
}
}
18 changes: 3 additions & 15 deletions src/Traits/BalanceOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ trait BalanceOperation

/**
* Check if Balance is more than zero.
*
* @return bool
*/
public function hasBalance(): bool
{
Expand All @@ -21,10 +19,7 @@ public function hasBalance(): bool
/**
* Decrement Balance and create a log entry.
*
* @param int|float $value
* @param ?string $notes
*
* @return void
* @param ?string $notes
*/
public function decrementAndCreateLog(int|float $value, ?string $notes = null): void
{
Expand All @@ -35,10 +30,7 @@ public function decrementAndCreateLog(int|float $value, ?string $notes = null):
/**
* Increment Balance and create a log entry.
*
* @param int|float $value
* @param ?string $notes
*
* @return void
* @param ?string $notes
*/
public function incrementAndCreateLog(int|float $value, ?string $notes = null): void
{
Expand All @@ -49,11 +41,7 @@ public function incrementAndCreateLog(int|float $value, ?string $notes = null):
/**
* Create a new log record
*
* @param string $logType
* @param int|float $value
* @param ?string $notes
*
* @return void
* @param ?string $notes
*/
protected function createLog(string $logType, int|float $value, ?string $notes = null): void
{
Expand Down
12 changes: 3 additions & 9 deletions src/Traits/HandlesDeposit.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ trait HandlesDeposit
/**
* Deposit an amount to the user's wallet of a specific type.
*
* @param string $type
* @param int|float $amount
* @param ?string $notes
* @param ?string $notes
*
* @return bool
* @throws InvalidDepositException|InvalidValueException|InvalidWalletTypeException
*/
public function deposit(string $type, int|float $amount, ?string $notes = null): bool
Expand All @@ -45,8 +42,6 @@ public function deposit(string $type, int|float $amount, ?string $notes = null):

/**
* Get depositable types from WalletEnums.
*
* @return array
*/
private function getDepositableTypes(): array
{
Expand All @@ -61,10 +56,9 @@ private function getDepositableTypes(): array
/**
* Check if the given type is valid.
*
* @var string $type
* @var array $depositable
* @var string
* @var array
*
* @return bool
* @throws InvalidWalletTypeException
*/
private function isRequestValid($type, array $depositable): bool
Expand Down
4 changes: 1 addition & 3 deletions src/Traits/HandlesPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ trait HandlesPayment
/**
* Pay the order value from the user's wallets.
*
* @param int|float $orderValue
* @param ?string $notes
* @param ?string $notes
*
* @return void
* @throws \HPWebdeveloper\LaravelPayPocket\Exceptions\InsufficientBalanceException
*/
public function pay(int|float $orderValue, ?string $notes = null): void
Expand Down
12 changes: 0 additions & 12 deletions src/Traits/HasWallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public function wallets()

/**
* Get User's Wallet Balance
*
* @return int|float
*/
public function getWalletBalanceAttribute(): int|float
{
Expand All @@ -45,24 +43,14 @@ public function getWalletBalanceAttribute(): int|float

/**
* Check if User's wallet balance is more than given value
*
* @param int|float $value
*
* @return bool
*/
public function hasSufficientBalance(int|float $value): bool
{
return (int) $this->walletBalance >= (int) $value;
}


/**
* Get the balance of a specific wallet type.
*
*
* @param string $walletType
*
* @return float|int
*/
public function getWalletBalanceByType(string $walletType): float|int
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
class User extends Authenticatable implements WalletOperations
{
use HasFactory;
use Notifiable;
use ManagesWallet;
use Notifiable;

/**
* The attributes that are mass assignable.
Expand Down

0 comments on commit 356afde

Please sign in to comment.