@@ -107,7 +107,7 @@ |
||
| 107 | 107 | * @return HttpResponse |
| 108 | 108 | */ |
| 109 | 109 | protected static function error(Exception $exception, $exception_type, $default_api_code, |
| 110 | - $default_http_code = ResponseBuilder::DEFAULT_HTTP_CODE_ERROR): HttpResponse |
|
| 110 | + $default_http_code = ResponseBuilder::DEFAULT_HTTP_CODE_ERROR): HttpResponse |
|
| 111 | 111 | { |
| 112 | 112 | // common prefix for config key |
| 113 | 113 | $base_config = 'response_builder.exception_handler.exception'; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @return HttpResponse |
| 185 | 185 | */ |
| 186 | 186 | public static function success($data = null, $api_code = null, array $lang_args = null, |
| 187 | - int $http_code = null, int $encoding_options = null): HttpResponse |
|
| 187 | + int $http_code = null, int $encoding_options = null): HttpResponse |
|
| 188 | 188 | { |
| 189 | 189 | return static::buildSuccessResponse($data, $api_code, $lang_args, $http_code, $encoding_options); |
| 190 | 190 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @throws \InvalidArgumentException Thrown when provided arguments are invalid. |
| 230 | 230 | */ |
| 231 | 231 | protected static function buildSuccessResponse($data = null, int $api_code = null, array $lang_args = null, |
| 232 | - int $http_code = null, int $encoding_options = null): HttpResponse |
|
| 232 | + int $http_code = null, int $encoding_options = null): HttpResponse |
|
| 233 | 233 | { |
| 234 | 234 | $http_code = $http_code ?? static::DEFAULT_HTTP_CODE_OK; |
| 235 | 235 | $api_code = $api_code ?? BaseApiCodes::OK(); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @return HttpResponse |
| 256 | 256 | */ |
| 257 | 257 | public static function error(int $api_code, array $lang_args = null, $data = null, int $http_code = null, |
| 258 | - int $encoding_options = null): HttpResponse |
|
| 258 | + int $encoding_options = null): HttpResponse |
|
| 259 | 259 | { |
| 260 | 260 | return static::buildErrorResponse($data, $api_code, $http_code, $lang_args, $encoding_options); |
| 261 | 261 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @return HttpResponse |
| 271 | 271 | */ |
| 272 | 272 | public static function errorWithData(int $api_code, $data, array $lang_args = null, |
| 273 | - int $encoding_options = null): HttpResponse |
|
| 273 | + int $encoding_options = null): HttpResponse |
|
| 274 | 274 | { |
| 275 | 275 | return static::buildErrorResponse($data, $api_code, null, $lang_args, $encoding_options); |
| 276 | 276 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @throws \InvalidArgumentException if http_code is @null |
| 289 | 289 | */ |
| 290 | 290 | public static function errorWithDataAndHttpCode(int $api_code, $data, int $http_code, array $lang_args = null, |
| 291 | - int $encoding_options = null): HttpResponse |
|
| 291 | + int $encoding_options = null): HttpResponse |
|
| 292 | 292 | { |
| 293 | 293 | return static::buildErrorResponse($data, $api_code, $http_code, $lang_args, $encoding_options); |
| 294 | 294 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @return HttpResponse |
| 319 | 319 | */ |
| 320 | 320 | public static function errorWithMessageAndData(int $api_code, string $error_message, $data, |
| 321 | - int $http_code = null, int $encoding_options = null): HttpResponse |
|
| 321 | + int $http_code = null, int $encoding_options = null): HttpResponse |
|
| 322 | 322 | { |
| 323 | 323 | return static::buildErrorResponse($data, $api_code, $http_code, null, |
| 324 | 324 | $error_message, null, $encoding_options); |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | * @return HttpResponse |
| 337 | 337 | */ |
| 338 | 338 | public static function errorWithMessageAndDataAndDebug(int $api_code, string $error_message, $data, |
| 339 | - int $http_code = null, int $encoding_options = null, |
|
| 340 | - array $debug_data = null): HttpResponse |
|
| 339 | + int $http_code = null, int $encoding_options = null, |
|
| 340 | + array $debug_data = null): HttpResponse |
|
| 341 | 341 | { |
| 342 | 342 | return static::buildErrorResponse($data, $api_code, $http_code, null, |
| 343 | 343 | $error_message, null, $encoding_options, $debug_data); |
@@ -376,8 +376,8 @@ discard block |
||
| 376 | 376 | * @noinspection MoreThanThreeArgumentsInspection |
| 377 | 377 | */ |
| 378 | 378 | protected static function buildErrorResponse($data, int $api_code, int $http_code = null, array $lang_args = null, |
| 379 | - string $message = null, array $headers = null, int $encoding_options = null, |
|
| 380 | - array $debug_data = null): HttpResponse |
|
| 379 | + string $message = null, array $headers = null, int $encoding_options = null, |
|
| 380 | + array $debug_data = null): HttpResponse |
|
| 381 | 381 | { |
| 382 | 382 | $http_code = $http_code ?? static::DEFAULT_HTTP_CODE_ERROR; |
| 383 | 383 | $headers = $headers ?? []; |
@@ -420,8 +420,8 @@ discard block |
||
| 420 | 420 | * @noinspection MoreThanThreeArgumentsInspection |
| 421 | 421 | */ |
| 422 | 422 | protected static function make(bool $success, int $api_code, $message_or_api_code, $data = null, |
| 423 | - int $http_code = null, array $lang_args = null, array $headers = null, |
|
| 424 | - int $encoding_options = null, array $debug_data = null): HttpResponse |
|
| 423 | + int $http_code = null, array $lang_args = null, array $headers = null, |
|
| 424 | + int $encoding_options = null, array $debug_data = null): HttpResponse |
|
| 425 | 425 | { |
| 426 | 426 | $headers = $headers ?? []; |
| 427 | 427 | $http_code = $http_code ?? ($success ? static::DEFAULT_HTTP_CODE_OK : static::DEFAULT_HTTP_CODE_ERROR); |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @throws \RuntimeException in case of missing or invalid "classes" mapping configuration |
| 478 | 478 | */ |
| 479 | 479 | protected static function buildResponse(bool $success, int $api_code, string $message, $data = null, |
| 480 | - array $debug_data = null): array |
|
| 480 | + array $debug_data = null): array |
|
| 481 | 481 | { |
| 482 | 482 | // ensure $data is either @null, array or object of class with configured mapping. |
| 483 | 483 | if ($data !== null) { |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | } elseif (is_object($data_val)) { |
| 164 | 164 | $obj_class_name = get_class($data_val); |
| 165 | 165 | if (array_key_exists($obj_class_name, $classes)) { |
| 166 | - $conversion_method = $classes[ $obj_class_name ][ static::KEY_METHOD ]; |
|
| 166 | + $conversion_method = $classes[$obj_class_name][static::KEY_METHOD]; |
|
| 167 | 167 | $converted = $data_val->$conversion_method(); |
| 168 | - $data[ $data_key ] = $converted; |
|
| 168 | + $data[$data_key] = $converted; |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | } elseif (is_object($data)) { |
| 501 | 501 | $obj_class_name = get_class($data); |
| 502 | 502 | if (array_key_exists($obj_class_name, $classes)) { |
| 503 | - $conversion_method = $classes[ $obj_class_name ][ static::KEY_METHOD ]; |
|
| 504 | - $data = [$classes[ $obj_class_name ][ static::KEY_KEY ] => $data->$conversion_method()]; |
|
| 503 | + $conversion_method = $classes[$obj_class_name][static::KEY_METHOD]; |
|
| 504 | + $data = [$classes[$obj_class_name][static::KEY_KEY] => $data->$conversion_method()]; |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | } |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | if ($data !== null && !is_object($data)) { |
| 511 | 511 | // ensure we get object in final JSON structure in data node |
| 512 | - $data = (object)$data; |
|
| 512 | + $data = (object) $data; |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** @noinspection PhpUndefinedClassInspection */ |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | |
| 524 | 524 | if ($debug_data !== null) { |
| 525 | 525 | $debug_key = Config::get(static::CONF_KEY_DEBUG_DEBUG_KEY, self::KEY_DEBUG); |
| 526 | - $response[ $debug_key ] = $debug_data; |
|
| 526 | + $response[$debug_key] = $debug_data; |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | return $response; |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | if (is_numeric($key)) { |
| 93 | 93 | continue; |
| 94 | 94 | } |
| 95 | - $array[ $key ] = $this->mergeConfig($value, $merging[ $key ]); |
|
| 95 | + $array[$key] = $this->mergeConfig($value, $merging[$key]); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return $array; |
@@ -112,7 +112,7 @@ |
||
| 112 | 112 | |
| 113 | 113 | $map = static::getMap(); |
| 114 | 114 | |
| 115 | - return $map[ $api_code ] ?? null; |
|
| 115 | + return $map[$api_code] ?? null; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public static function isCodeValid($code): bool |