Skip to content

Commit d661d59

Browse files
Merge pull request #16 from HPWebdeveloper/types
Correcting Types and Fix-Styling
2 parents aa174d1 + 174ab31 commit d661d59

18 files changed

+139
-77
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ LaravelPayPocket::deposit($user, 'wallet_1', 123.45);
137137

138138
Note: `wallet_1` and `wallet_2` must already be defined in the `WalletEnums`.
139139

140-
#### Transaction Notes ([#8][i8])
140+
#### Transaction Info ([#8][i8])
141141

142142
When you need to add descriptions for a specific transaction, the `$notes` parameter enables you to provide details explaining the reason behind the transaction.
143143

config/pay-pocket.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
return [
1616
'log_reference_length' => 12,
17-
'log_reference_prefix' => null,
18-
'log_reference_generator' => null,
17+
'log_reference_prefix' => '',
18+
'log_reference_generator_class' => Illuminate\Support\Str::class,
19+
'log_reference_generator_method' => 'random',
1920
];

src/Exceptions/InsufficientBalanceException.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
namespace HPWebdeveloper\LaravelPayPocket\Exceptions;
44

55
use Exception;
6+
use Throwable;
67

78
class InsufficientBalanceException extends Exception
89
{
9-
/**
10-
* Construct the exception.
11-
*
12-
* @param string $message
13-
* @param int $code
14-
*/
15-
public function __construct($message = 'Insufficient balance to cover the order', $code = 0, ?\Throwable $previous = null)
10+
public function __construct(string $message = 'Insufficient balance to cover the order', int $code = 0, ?Throwable $previous = null)
1611
{
1712
parent::__construct($message, $code, $previous);
1813
}

src/Exceptions/InvalidDepositException.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
namespace HPWebdeveloper\LaravelPayPocket\Exceptions;
44

55
use Exception;
6+
use Throwable;
67

78
class InvalidDepositException extends Exception
89
{
9-
/**
10-
* Construct the exception.
11-
*
12-
* @param string $message
13-
* @param int $code
14-
*/
15-
public function __construct($message = 'Invalid deposit operation', $code = 0, ?\Throwable $previous = null)
10+
public function __construct(string $message = 'Invalid deposit operation', int $code = 0, ?Throwable $previous = null)
1611
{
1712
parent::__construct($message, $code, $previous);
1813
}

src/Exceptions/InvalidValueException.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
namespace HPWebdeveloper\LaravelPayPocket\Exceptions;
44

55
use Exception;
6+
use Throwable;
67

78
class InvalidValueException extends Exception
89
{
9-
/**
10-
* Construct the exception.
11-
*
12-
* @param string $message
13-
* @param int $code
14-
*/
15-
public function __construct($message = 'Invalie value to deposit', $code = 0, ?\Throwable $previous = null)
10+
public function __construct(string $message = 'Invalie value to deposit', int $code = 0, ?Throwable $previous = null)
1611
{
1712
parent::__construct($message, $code, $previous);
1813
}

src/Exceptions/InvalidWalletTypeException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace HPWebdeveloper\LaravelPayPocket\Exceptions;
44

55
use Exception;
6+
use Throwable;
67

78
class InvalidWalletTypeException extends Exception
89
{
9-
public function __construct($message = 'Invalid wallet type', $code = 0, ?\Throwable $previous = null)
10+
public function __construct(string $message = 'Invalid wallet type', int $code = 0, ?Throwable $previous = null)
1011
{
1112
parent::__construct($message, $code, $previous);
1213
}

src/Exceptions/WalletNotFoundException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace HPWebdeveloper\LaravelPayPocket\Exceptions;
44

55
use Exception;
6+
use Throwable;
67

78
class WalletNotFoundException extends Exception
89
{
9-
public function __construct($message = 'Wallet not found', $code = 0, ?\Throwable $previous = null)
10+
public function __construct(string $message = 'Wallet not found', int $code = 0, ?Throwable $previous = null)
1011
{
1112
parent::__construct($message, $code, $previous);
1213
}

src/Facades/LaravelPayPocket.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
namespace HPWebdeveloper\LaravelPayPocket\Facades;
44

5+
use HPWebdeveloper\LaravelPayPocket\Interfaces\WalletOperations;
56
use Illuminate\Support\Facades\Facade;
67

78
/**
89
* @see \HPWebdeveloper\LaravelPayPocket\Services\PocketServices
10+
*
11+
* @method static void pay(WalletOperations $user, int|float $orderValue, ?string $notes = null)
12+
* @method static bool deposit(WalletOperations $user, string $type, int|float $amount, ?string $notes = null)
13+
* @method static int|float checkBalance(WalletOperations $user)
14+
* @method static int|float walletBalanceByType(WalletOperations $user, string $type)
915
*/
1016
class LaravelPayPocket extends Facade
1117
{
12-
protected static function getFacadeAccessor()
18+
protected static function getFacadeAccessor(): string
1319
{
1420
return \HPWebdeveloper\LaravelPayPocket\Services\PocketServices::class;
1521
}

src/Interfaces/WalletOperations.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,39 @@
22

33
namespace HPWebdeveloper\LaravelPayPocket\Interfaces;
44

5+
use HPWebdeveloper\LaravelPayPocket\Exceptions\InsufficientBalanceException;
6+
57
interface WalletOperations
68
{
7-
public function getWalletBalanceAttribute();
9+
/**
10+
* Get User's Wallet Balance
11+
*/
12+
public function getWalletBalanceAttribute(): int|float;
813

9-
public function getWalletBalanceByType(string $walletType);
14+
/**
15+
* Get the balance of a specific wallet type.
16+
*/
17+
public function getWalletBalanceByType(string $walletType): int|float;
1018

11-
public function hasSufficientBalance($value): bool;
19+
/**
20+
* Check if User's wallet balance is more than given value
21+
*/
22+
public function hasSufficientBalance(int|float $value): bool;
1223

13-
public function pay(int|float $orderValue, ?string $notes = null);
24+
/**
25+
* Pay the order value from the user's wallets.
26+
*
27+
* @throws InsufficientBalanceException
28+
*/
29+
public function pay(int|float $orderValue, ?string $notes = null): void;
1430

31+
/**
32+
* Deposit an amount to the user's wallet of a specific type.
33+
*/
1534
public function deposit(string $type, int|float $amount, ?string $notes = null): bool;
35+
36+
/**
37+
* Get user's wallet balance.
38+
*/
39+
public function getWalletBalance(): int|float;
1640
}

src/Models/WalletsLog.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
* HPWebdeveloper\LaravelPayPocket\Models\WalletsLog
1111
*
1212
* @property string $status
13+
* @property int|float $from
14+
* @property int|float $to
15+
* @property string $type
16+
* @property string $ip
17+
* @property int|float $value
18+
* @property string $wallet_name
19+
* @property string $notes
20+
* @property string $reference
1321
*/
1422
class WalletsLog extends Model
1523
{

0 commit comments

Comments
 (0)