@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | $this->app->runningInConsole() |
17 | 17 | ) { |
18 | 18 | $this->publishes([ |
19 | - __DIR__.'/../config/config.php' => config_path('paystack.php'), |
|
19 | + __DIR__ . '/../config/config.php' => config_path('paystack.php'), |
|
20 | 20 | ], 'config'); |
21 | 21 | } |
22 | 22 | |
23 | 23 | // Register custom validation rule for Laravel 10+ |
24 | - Validator::extend('required_string', function ($attribute, $value, $parameters, $validator) { |
|
25 | - return is_string($value) && ! empty(trim($value)); |
|
24 | + Validator::extend('required_string', function($attribute, $value, $parameters, $validator) { |
|
25 | + return is_string($value) && !empty(trim($value)); |
|
26 | 26 | }, 'The :attribute must be a non-empty string.'); |
27 | 27 | } |
28 | 28 | |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | public function register(): void |
33 | 33 | { |
34 | 34 | // Automatically apply the package configuration |
35 | - $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'paystack'); |
|
35 | + $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'paystack'); |
|
36 | 36 | |
37 | 37 | // Register the main class to use with the facade |
38 | - $this->app->bind('paystack', function () { |
|
38 | + $this->app->bind('paystack', function() { |
|
39 | 39 | // Validate required credentials |
40 | 40 | $config = config('paystack'); |
41 | 41 | |
42 | - if (empty($config['secret_key'])) { |
|
42 | + if (empty($config[ 'secret_key' ])) { |
|
43 | 43 | throw new \InvalidArgumentException('Paystack secret key is required. Please set PAYSTACK_SECRET_KEY in your .env file.'); |
44 | 44 | } |
45 | 45 | |
46 | - return new Paystack($config['secret_key']); |
|
46 | + return new Paystack($config[ 'secret_key' ]); |
|
47 | 47 | }); |
48 | 48 | } |
49 | 49 | } |
@@ -47,8 +47,8 @@ |
||
47 | 47 | */ |
48 | 48 | public static function fromResponse(array $response, string $endpoint): self |
49 | 49 | { |
50 | - $message = $response['message'] ?? 'Unknown API error'; |
|
51 | - $code = $response['status'] ?? 0; |
|
50 | + $message = $response[ 'message' ] ?? 'Unknown API error'; |
|
51 | + $code = $response[ 'status' ] ?? 0; |
|
52 | 52 | |
53 | 53 | return new self($message, $code, $endpoint, $response); |
54 | 54 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | class PaystackException extends Exception |
11 | 11 | { |
12 | 12 | /** @var array<string, mixed> */ |
13 | - protected array $context = []; |
|
13 | + protected array $context = [ ]; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param array<string, mixed> $context |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | string $message = '', |
20 | 20 | int $code = 0, |
21 | 21 | ?Exception $previous = null, |
22 | - array $context = [] |
|
22 | + array $context = [ ] |
|
23 | 23 | ) { |
24 | 24 | parent::__construct($message, $code, $previous); |
25 | 25 | $this->context = $context; |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | class PaystackValidationException extends PaystackException |
11 | 11 | { |
12 | 12 | /** @var array<string, string> */ |
13 | - protected array $errors = []; |
|
13 | + protected array $errors = [ ]; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param array<string, string> $errors |
17 | 17 | */ |
18 | 18 | public function __construct( |
19 | 19 | string $message = '', |
20 | - array $errors = [], |
|
20 | + array $errors = [ ], |
|
21 | 21 | int $code = 0, |
22 | 22 | ?Exception $previous = null |
23 | 23 | ) { |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | public function addError(string $field, string $message): self |
37 | 37 | { |
38 | - $this->errors[$field] = $message; |
|
38 | + $this->errors[ $field ] = $message; |
|
39 | 39 | |
40 | 40 | return $this; |
41 | 41 | } |
42 | 42 | |
43 | 43 | public function hasErrors(): bool |
44 | 44 | { |
45 | - return ! empty($this->errors); |
|
45 | + return !empty($this->errors); |
|
46 | 46 | } |
47 | 47 | } |