@@ -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 | /** |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | // check for exact class name match... |
| 73 | 73 | $cls = get_class($data); |
| 74 | 74 | if (array_key_exists($cls, $this->classes)) { |
| 75 | - $result = $this->classes[ $cls ]; |
|
| 75 | + $result = $this->classes[$cls]; |
|
| 76 | 76 | } else { |
| 77 | 77 | // no exact match, then lets try with `instanceof` |
| 78 | 78 | foreach (array_keys($this->classes) as $class_name) { |
| 79 | 79 | if ($data instanceof $class_name) { |
| 80 | - $result = $this->classes[ $class_name ]; |
|
| 80 | + $result = $this->classes[$class_name]; |
|
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | if (is_object($data)) { |
| 109 | 109 | $cfg = $this->getClassMappingConfigOrThrow($data); |
| 110 | - $data = [$cfg[ ResponseBuilder::KEY_KEY ] => $data->{$cfg[ ResponseBuilder::KEY_METHOD ]}()]; |
|
| 110 | + $data = [$cfg[ResponseBuilder::KEY_KEY] => $data->{$cfg[ResponseBuilder::KEY_METHOD]}()]; |
|
| 111 | 111 | } elseif (!is_array($data)) { |
| 112 | 112 | throw new \InvalidArgumentException( |
| 113 | 113 | sprintf('Payload must be null, array or object with mapping ("%s" given).', gettype($data))); |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | foreach ($data as $key => $val) { |
| 151 | 151 | if (is_array($val)) { |
| 152 | - $data[ $key ] = $this->convertArray($val); |
|
| 152 | + $data[$key] = $this->convertArray($val); |
|
| 153 | 153 | } elseif (is_object($val)) { |
| 154 | 154 | $cls = get_class($val); |
| 155 | 155 | if (array_key_exists($cls, $this->classes)) { |
| 156 | - $conversion_method = $this->classes[ $cls ][ ResponseBuilder::KEY_METHOD ]; |
|
| 156 | + $conversion_method = $this->classes[$cls][ResponseBuilder::KEY_METHOD]; |
|
| 157 | 157 | $converted_data = $val->$conversion_method(); |
| 158 | - $data[ $key ] = $converted_data; |
|
| 158 | + $data[$key] = $converted_data; |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -34,20 +34,20 @@ |
||
| 34 | 34 | $array = $original; |
| 35 | 35 | foreach ($merging as $m_key => $m_val) { |
| 36 | 36 | if (array_key_exists($m_key, $original)) { |
| 37 | - $orig_type = gettype($original[ $m_key ]); |
|
| 37 | + $orig_type = gettype($original[$m_key]); |
|
| 38 | 38 | $m_type = gettype($m_val); |
| 39 | 39 | if ($orig_type !== $m_type) { |
| 40 | 40 | throw new \RuntimeException( |
| 41 | 41 | "Incompatible types. Cannot merge {$m_type} into {$orig_type} (key '{$m_key}')."); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if (is_array($merging[ $m_key ])) { |
|
| 45 | - $array[ $m_key ] = static::mergeConfig($original[ $m_key ], $m_val); |
|
| 44 | + if (is_array($merging[$m_key])) { |
|
| 45 | + $array[$m_key] = static::mergeConfig($original[$m_key], $m_val); |
|
| 46 | 46 | } else { |
| 47 | - $array[ $m_key ] = $m_val; |
|
| 47 | + $array[$m_key] = $m_val; |
|
| 48 | 48 | } |
| 49 | 49 | } else { |
| 50 | - $array[ $m_key ] = $m_val; |
|
| 50 | + $array[$m_key] = $m_val; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | // Check if we have any exception configuration for this particular Http status code. |
| 45 | 45 | // This confing entry is guaranted to exist (at least 'default'). Enforced by tests. |
| 46 | 46 | $http_code = $ex->getStatusCode(); |
| 47 | - $ex_cfg = $cfg[ HttpException::class ][ $http_code ] ?? null; |
|
| 48 | - $ex_cfg = $ex_cfg ?? $cfg[ HttpException::class ]['default']; |
|
| 47 | + $ex_cfg = $cfg[HttpException::class][$http_code] ?? null; |
|
| 48 | + $ex_cfg = $ex_cfg ?? $cfg[HttpException::class]['default']; |
|
| 49 | 49 | $result = self::processException($ex, $ex_cfg, $http_code); |
| 50 | 50 | } elseif ($ex instanceof ValidationException) { |
| 51 | 51 | // This entry is guaranted to exist. Enforced by tests. |
| 52 | 52 | $http_code = HttpResponse::HTTP_UNPROCESSABLE_ENTITY; |
| 53 | - $ex_cfg = $cfg[ HttpException::class ][ $http_code ]; |
|
| 53 | + $ex_cfg = $cfg[HttpException::class][$http_code]; |
|
| 54 | 54 | $result = self::processException($ex, $ex_cfg, $http_code); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $result = static::error($ex, $api_code, $http_code, $error_message); |
| 97 | 97 | |
| 98 | 98 | if ($result === null) { |
| 99 | - $ex_cfg = $cfg[ HttpException::class ][ $http_code ]; |
|
| 99 | + $ex_cfg = $cfg[HttpException::class][$http_code]; |
|
| 100 | 100 | $api_code = $ex_cfg['api_code'] ?? BaseApiCodes::EX_VALIDATION_EXCEPTION(); |
| 101 | 101 | $http_code = $ex_cfg['http_code'] ?? $http_code; |
| 102 | 102 | $result = static::error($ex, $api_code, $http_code, $error_message); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | // This entry is guaranted to exist. Enforced by tests. |
| 146 | 146 | $http_code = HttpResponse::HTTP_UNAUTHORIZED; |
| 147 | - $cfg = static::getExceptionHandlerConfig()['map'][ HttpException::class ][ $http_code ]; |
|
| 147 | + $cfg = static::getExceptionHandlerConfig()['map'][HttpException::class][$http_code]; |
|
| 148 | 148 | |
| 149 | 149 | return static::processException($exception, $cfg, $http_code); |
| 150 | 150 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $data = $converter->convert($data); |
| 242 | 242 | if ($data !== null && !is_object($data)) { |
| 243 | 243 | // ensure we get object in final JSON structure in data node |
| 244 | - $data = (object)$data; |
|
| 244 | + $data = (object) $data; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // get human readable message for API code or use message string (if given instead of API code) |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | if ($debug_data !== null) { |
| 265 | 265 | $debug_key = Config::get(ResponseBuilder::CONF_KEY_DEBUG_DEBUG_KEY, ResponseBuilder::KEY_DEBUG); |
| 266 | - $response[ $debug_key ] = $debug_data; |
|
| 266 | + $response[$debug_key] = $debug_data; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | return $response; |