@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public static function checkSlugAvailability($slug) |
21 | 21 | { |
22 | - $slug = 'check_slug_availability/'.$slug; |
|
22 | + $slug = 'check_slug_availability/' . $slug; |
|
23 | 23 | $url = static::endPointUrl($slug); |
24 | 24 | |
25 | 25 | return static::staticRequest('GET', $url); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public static function addProducts($page_id, $params) |
35 | 35 | { |
36 | 36 | self::validateParams($params, true); |
37 | - $url = static::resourceUrl($page_id).'/product'; |
|
37 | + $url = static::resourceUrl($page_id) . '/product'; |
|
38 | 38 | |
39 | 39 | return static::staticRequest('POST', $url); |
40 | 40 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | public static function ledger($params) |
19 | 19 | { |
20 | 20 | self::validateParams($params, true); |
21 | - $url = static::classUrl().'/ledger'; |
|
21 | + $url = static::classUrl() . '/ledger'; |
|
22 | 22 | |
23 | 23 | return static::staticRequest('get', $url); |
24 | 24 | } |
@@ -79,7 +79,7 @@ |
||
79 | 79 | public static function resendOtp($params) |
80 | 80 | { |
81 | 81 | self::validateParams($params, true); |
82 | - $url = static::classUrl().'/resend_otp'; |
|
82 | + $url = static::classUrl() . '/resend_otp'; |
|
83 | 83 | |
84 | 84 | return static::staticRequest('POST', $url, $params); |
85 | 85 | } |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | if (null === self::$isMbstringAvailable) { |
22 | 22 | self::$isMbstringAvailable = function_exists('mb_detect_encoding'); |
23 | 23 | |
24 | - if (! self::$isMbstringAvailable) { |
|
25 | - trigger_error('It looks like the mbstring extension is not enabled. '. |
|
26 | - 'UTF-8 strings will not properly be encoded. Ask your system '. |
|
24 | + if (!self::$isMbstringAvailable) { |
|
25 | + trigger_error('It looks like the mbstring extension is not enabled. ' . |
|
26 | + 'UTF-8 strings will not properly be encoded. Ask your system ' . |
|
27 | 27 | 'administrator to enable the mbstring extension.', E_USER_WARNING); |
28 | 28 | } |
29 | 29 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function convertArrayToObject($resp) |
46 | 46 | { |
47 | - if (! is_array($resp)) { |
|
47 | + if (!is_array($resp)) { |
|
48 | 48 | $message = 'The response passed must be an array'; |
49 | 49 | |
50 | 50 | throw new InvalidArgumentException($message); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | |
37 | 37 | private static function validateApiKey($apiKey): bool |
38 | 38 | { |
39 | - if ($apiKey == '' || ! is_string($apiKey)) { |
|
39 | + if ($apiKey == '' || !is_string($apiKey)) { |
|
40 | 40 | throw new InvalidArgumentException('Api key must be a string and cannot be empty'); |
41 | 41 | } |
42 | 42 |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | public static function validateParams($params = null, $required = false): void |
34 | 34 | { |
35 | 35 | if ($required) { |
36 | - if (empty($params) || ! is_array($params)) { |
|
36 | + if (empty($params) || !is_array($params)) { |
|
37 | 37 | $message = 'The parameter passed must be an array and must not be empty'; |
38 | 38 | |
39 | 39 | throw new InvalidArgumentException($message); |
40 | 40 | } |
41 | 41 | } |
42 | - if ($params && ! is_array($params)) { |
|
42 | + if ($params && !is_array($params)) { |
|
43 | 43 | $message = 'The parameter passed must be an array'; |
44 | 44 | |
45 | 45 | throw new InvalidArgumentException($message); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return array|object (the JSON response as array or object) |
59 | 59 | */ |
60 | - public static function staticRequest($method, $url, $params = [], $return_type = 'obj') |
|
60 | + public static function staticRequest($method, $url, $params = [ ], $return_type = 'obj') |
|
61 | 61 | { |
62 | 62 | if ($return_type != 'arr' && $return_type != 'obj') { |
63 | 63 | throw new InvalidArgumentException('Return type can only be obj or arr'); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | protected static function setRequestOptions(): void |
78 | 78 | { |
79 | - $authBearer = 'Bearer '.Paystack::$apiKey; |
|
79 | + $authBearer = 'Bearer ' . Paystack::$apiKey; |
|
80 | 80 | |
81 | 81 | static::$client = new Client( |
82 | 82 | [ |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @throws IsNullException |
99 | 99 | */ |
100 | - private static function setHttpResponse($method, $url, $body = []): \GuzzleHttp\Psr7\Response |
|
100 | + private static function setHttpResponse($method, $url, $body = [ ]): \GuzzleHttp\Psr7\Response |
|
101 | 101 | { |
102 | 102 | if (is_null($method)) { |
103 | 103 | throw new IsNullException('Empty method not allowed'); |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | static::setRequestOptions(); |
107 | 107 | |
108 | 108 | static::$response = static::$client->{strtolower($method)}( |
109 | - Paystack::$apiBase.'/'.$url, |
|
110 | - ['body' => json_encode($body)] |
|
109 | + Paystack::$apiBase . '/' . $url, |
|
110 | + [ 'body' => json_encode($body) ] |
|
111 | 111 | ); |
112 | 112 | |
113 | 113 | return static::$response; |
@@ -130,6 +130,6 @@ discard block |
||
130 | 130 | */ |
131 | 131 | private static function getResponseData(): array |
132 | 132 | { |
133 | - return json_decode(static::$response->getBody(), true)['data']; |
|
133 | + return json_decode(static::$response->getBody(), true)[ 'data' ]; |
|
134 | 134 | } |
135 | 135 | } |
@@ -13,8 +13,8 @@ |
||
13 | 13 | { |
14 | 14 | self::validateParams($params); |
15 | 15 | $url = static::classUrl(); |
16 | - if (! empty($params)) { |
|
17 | - $url .= '?'.http_build_query($params); |
|
16 | + if (!empty($params)) { |
|
17 | + $url .= '?' . http_build_query($params); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | return static::staticRequest('GET', $url); |
@@ -71,8 +71,8 @@ |
||
71 | 71 | public static function buildQueryString($slug, $params = null) |
72 | 72 | { |
73 | 73 | $url = self::endPointUrl($slug); |
74 | - if (! empty($params)) { |
|
75 | - $url .= '?'.http_build_query($params); |
|
74 | + if (!empty($params)) { |
|
75 | + $url .= '?' . http_build_query($params); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $url; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public static function validate($customerCode) |
22 | 22 | { |
23 | - $url = static::classUrl().'/{$customerCode}/identification'; |
|
23 | + $url = static::classUrl() . '/{$customerCode}/identification'; |
|
24 | 24 | |
25 | 25 | return static::staticRequest('POST', $url); |
26 | 26 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public static function whiteOrBlackList($params) |
42 | 42 | { |
43 | 43 | self::validateParams($params); |
44 | - $url = static::classUrl().'/set_risk_action'; |
|
44 | + $url = static::classUrl() . '/set_risk_action'; |
|
45 | 45 | |
46 | 46 | return static::staticRequest('POST', $url, $params); |
47 | 47 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public static function deactivateAuthorization($params) |
60 | 60 | { |
61 | 61 | self::validateParams($params); |
62 | - $url = static::classUrl().'/deactivate_authorization'; |
|
62 | + $url = static::classUrl() . '/deactivate_authorization'; |
|
63 | 63 | |
64 | 64 | return static::staticRequest('POST', $url, $params, 'arr'); |
65 | 65 | } |