@@ -50,7 +50,7 @@ |
||
| 50 | 50 | public static function buildQueryString($slug, $params = null) |
| 51 | 51 | { |
| 52 | 52 | $url = self::endPointUrl($slug); |
| 53 | - if (! empty($params)) { |
|
| 53 | + if (!empty($params)) { |
|
| 54 | 54 | $url .= '?'.http_build_query($params); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | private static function validateApiKey($apiKey) |
| 40 | 40 | { |
| 41 | - if ($apiKey == '' || ! is_string($apiKey)) { |
|
| 41 | + if ($apiKey == '' || !is_string($apiKey)) { |
|
| 42 | 42 | throw new InvalidArgumentException('Secret key must be a string and cannot be empty'); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | if (null === self::$isMbstringAvailable) { |
| 22 | 22 | self::$isMbstringAvailable = function_exists('mb_detect_encoding'); |
| 23 | 23 | |
| 24 | - if (! self::$isMbstringAvailable) { |
|
| 24 | + if (!self::$isMbstringAvailable) { |
|
| 25 | 25 | trigger_error('It looks like the mbstring extension is not enabled. '. |
| 26 | 26 | 'UTF-8 strings will not properly be encoded. Ask your system '. |
| 27 | 27 | 'administrator to enable the mbstring extension.', E_USER_WARNING); |
@@ -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); |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | public static function validateData(array $expectedKeys, array $data) |
| 73 | 73 | { |
| 74 | 74 | //check if array keys are empty |
| 75 | - if (! array_filter($data)) { |
|
| 75 | + if (!array_filter($data)) { |
|
| 76 | 76 | throw new \Digikraaft\Mono\Exceptions\InvalidArgumentException("Please check that all required keys are present and not null"); |
| 77 | 77 | } |
| 78 | - if (! self::in_array_all( |
|
| 78 | + if (!self::in_array_all( |
|
| 79 | 79 | $expectedKeys, |
| 80 | 80 | $data |
| 81 | 81 | )) { |
@@ -85,6 +85,6 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | protected static function in_array_all(array $expectedKeys, array $arrayOfData) : bool |
| 87 | 87 | { |
| 88 | - return ! array_diff_key(array_flip($expectedKeys), $arrayOfData); |
|
| 88 | + return !array_diff_key(array_flip($expectedKeys), $arrayOfData); |
|
| 89 | 89 | } |
| 90 | 90 | } |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | //24-04-2020 |
| 60 | 60 | self::validateParams($params); |
| 61 | 61 | $url = self::endPointUrl("date"); |
| 62 | - if (! empty($params)) { |
|
| 62 | + if (!empty($params)) { |
|
| 63 | 63 | $url .= '?'.http_build_query($params); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | public static function validateParams($params = null, $required = false): void |
| 37 | 37 | { |
| 38 | 38 | if ($required) { |
| 39 | - if (empty($params) || ! is_array($params)) { |
|
| 39 | + if (empty($params) || !is_array($params)) { |
|
| 40 | 40 | $message = 'The parameter passed must be an array and must not be empty'; |
| 41 | 41 | |
| 42 | 42 | throw new InvalidArgumentException($message); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | - if ($params && ! is_array($params)) { |
|
| 45 | + if ($params && !is_array($params)) { |
|
| 46 | 46 | $message = 'The parameter passed must be an array'; |
| 47 | 47 | |
| 48 | 48 | throw new InvalidArgumentException($message); |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return array|object (the JSON response as array or object) |
| 62 | 62 | */ |
| 63 | - public static function staticRequest($method, $url, $params = [], $return_type = Abokifx::ARRAY_RESPONSE) |
|
| 63 | + public static function staticRequest($method, $url, $params = [ ], $return_type = Abokifx::ARRAY_RESPONSE) |
|
| 64 | 64 | { |
| 65 | 65 | if (Abokifx::$responseType != Abokifx::ARRAY_RESPONSE && Abokifx::$responseType != Abokifx::OBJECT_RESPONSE) { |
| 66 | - throw new InvalidArgumentException('Return type can only be '. Abokifx::OBJECT_RESPONSE .' or '. Abokifx::ARRAY_RESPONSE); |
|
| 66 | + throw new InvalidArgumentException('Return type can only be '.Abokifx::OBJECT_RESPONSE.' or '.Abokifx::ARRAY_RESPONSE); |
|
| 67 | 67 | } |
| 68 | 68 | static::setHttpResponse($method, $url, $params); |
| 69 | 69 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | [ |
| 86 | 86 | 'base_uri' => Abokifx::$apiBaseUrl, |
| 87 | 87 | 'headers' => [ |
| 88 | - 'Authorization' => "Bearer " . $auth, |
|
| 88 | + 'Authorization' => "Bearer ".$auth, |
|
| 89 | 89 | 'Content-Type' => 'application/json', |
| 90 | 90 | 'Accept' => 'application/json', |
| 91 | 91 | ], |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @throws IsNullException |
| 102 | 102 | * @throws ApiErrorException |
| 103 | 103 | */ |
| 104 | - private static function setHttpResponse($method, $url, $body = []): \GuzzleHttp\Psr7\Response |
|
| 104 | + private static function setHttpResponse($method, $url, $body = [ ]): \GuzzleHttp\Psr7\Response |
|
| 105 | 105 | { |
| 106 | 106 | if (is_null($method)) { |
| 107 | 107 | throw new IsNullException('Empty method not allowed'); |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | try { |
| 113 | 113 | static::$response = static::$client->{strtolower($method)}( |
| 114 | - Abokifx::$apiBaseUrl . '/' . $url, |
|
| 115 | - ['body' => json_encode($body)] |
|
| 114 | + Abokifx::$apiBaseUrl.'/'.$url, |
|
| 115 | + [ 'body' => json_encode($body) ] |
|
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | 118 | return static::$response; |
@@ -138,6 +138,6 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | private static function getResponseData(): array |
| 140 | 140 | { |
| 141 | - return json_decode(static::$response->getBody(), true)['response']; |
|
| 141 | + return json_decode(static::$response->getBody(), true)[ 'response' ]; |
|
| 142 | 142 | } |
| 143 | 143 | } |