@@ -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 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $data = (new Converter())->convert($data); |
353 | 353 | if ($data !== null && !\is_object($data)) { |
354 | 354 | // ensure we get object in final JSON structure in data node |
355 | - $data = (object)$data; |
|
355 | + $data = (object) $data; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | // get human readable message for API code or use message string (if given instead of API code) |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | |
375 | 375 | if ($debug_data !== null) { |
376 | 376 | $debug_key = Config::get(ResponseBuilder::CONF_KEY_DEBUG_DEBUG_KEY, ResponseBuilder::KEY_DEBUG); |
377 | - $response[ $debug_key ] = $debug_data; |
|
377 | + $response[$debug_key] = $debug_data; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | return $response; |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | // check for exact class name match... |
67 | 67 | $cls = \get_class($data); |
68 | 68 | if (\array_key_exists($cls, $this->classes)) { |
69 | - $result = $this->classes[ $cls ]; |
|
69 | + $result = $this->classes[$cls]; |
|
70 | 70 | } else { |
71 | 71 | // no exact match, then lets try with `instanceof` |
72 | 72 | foreach (\array_keys($this->getClasses()) as $class_name) { |
73 | 73 | if ($data instanceof $class_name) { |
74 | - $result = $this->classes[ $class_name ]; |
|
74 | + $result = $this->classes[$class_name]; |
|
75 | 75 | break; |
76 | 76 | } |
77 | 77 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | if (\is_object($data)) { |
106 | 106 | $cfg = $this->getClassMappingConfigOrThrow($data); |
107 | - $worker = new $cfg[ ResponseBuilder::KEY_HANDLER ](); |
|
107 | + $worker = new $cfg[ResponseBuilder::KEY_HANDLER](); |
|
108 | 108 | $data = $worker->convert($data, $cfg); |
109 | 109 | } else { |
110 | 110 | $data = $this->convertArray($data); |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | |
147 | 147 | foreach ($data as $key => $val) { |
148 | 148 | if (\is_array($val)) { |
149 | - $data[ $key ] = $this->convertArray($val); |
|
149 | + $data[$key] = $this->convertArray($val); |
|
150 | 150 | } elseif (\is_object($val)) { |
151 | 151 | $cfg = $this->getClassMappingConfigOrThrow($val); |
152 | - $worker = new $cfg[ ResponseBuilder::KEY_HANDLER ](); |
|
152 | + $worker = new $cfg[ResponseBuilder::KEY_HANDLER](); |
|
153 | 153 | $converted_data = $worker->convert($val, $cfg); |
154 | - $data[ $key ] = $converted_data; |
|
154 | + $data[$key] = $converted_data; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 |
@@ -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 |
@@ -42,17 +42,17 @@ |
||
42 | 42 | $config = \array_replace($default_config, $user_config); |
43 | 43 | |
44 | 44 | $http_code = $ex->getStatusCode(); |
45 | - $result = $config[ $http_code ] ?? null; |
|
45 | + $result = $config[$http_code] ?? null; |
|
46 | 46 | |
47 | 47 | if ($result === null) { |
48 | - $result = $config[ ResponseBuilder::KEY_DEFAULT ]; |
|
48 | + $result = $config[ResponseBuilder::KEY_DEFAULT]; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | if (!\array_key_exists(ResponseBuilder::KEY_HTTP_CODE, $result)) { |
52 | - $result[ ResponseBuilder::KEY_HTTP_CODE ] = $http_code; |
|
52 | + $result[ResponseBuilder::KEY_HTTP_CODE] = $http_code; |
|
53 | 53 | } |
54 | 54 | if (\array_key_exists(ResponseBuilder::KEY_MSG_KEY, $result)) { |
55 | - $result[ ResponseBuilder::KEY_MSG_KEY ] = \sprintf('response-builder::builder.http_%d', $http_code); |
|
55 | + $result[ResponseBuilder::KEY_MSG_KEY] = \sprintf('response-builder::builder.http_%d', $http_code); |
|
56 | 56 | } |
57 | 57 | return $result; |
58 | 58 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | do { |
45 | 45 | if ($cfg === null) { |
46 | 46 | // Default handler MUST be present by design and always return something useful. |
47 | - $cfg = self::getExceptionHandlerConfig()[ ResponseBuilder::KEY_DEFAULT ]; |
|
47 | + $cfg = self::getExceptionHandlerConfig()[ResponseBuilder::KEY_DEFAULT]; |
|
48 | 48 | } |
49 | 49 | |
50 | - $handler = new $cfg[ ResponseBuilder::KEY_HANDLER ](); |
|
51 | - $handler_result = $handler->handle($cfg[ ResponseBuilder::KEY_CONFIG ], $ex); |
|
50 | + $handler = new $cfg[ResponseBuilder::KEY_HANDLER](); |
|
51 | + $handler_result = $handler->handle($cfg[ResponseBuilder::KEY_CONFIG], $ex); |
|
52 | 52 | if ($handler_result !== null) { |
53 | 53 | $result = self::processException($ex, $handler_result); |
54 | 54 | } else { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $cfg = self::getExceptionHandlerConfig(); |
148 | 148 | |
149 | 149 | // This config entry is guaranted to exist. Enforced by tests. |
150 | - $cfg = $cfg[ HttpException::class ][ ResponseBuilder::KEY_CONFIG ][ HttpResponse::HTTP_UNAUTHORIZED ]; |
|
150 | + $cfg = $cfg[HttpException::class][ResponseBuilder::KEY_CONFIG][HttpResponse::HTTP_UNAUTHORIZED]; |
|
151 | 151 | |
152 | 152 | return static::processException($exception, $cfg, HttpResponse::HTTP_UNAUTHORIZED); |
153 | 153 | } |
@@ -280,13 +280,13 @@ discard block |
||
280 | 280 | |
281 | 281 | // check for exact class name match... |
282 | 282 | if (\array_key_exists($cls, $cfg)) { |
283 | - $result = $cfg[ $cls ]; |
|
283 | + $result = $cfg[$cls]; |
|
284 | 284 | } else { |
285 | 285 | // no exact match, then lets try with `instanceof` |
286 | 286 | // Config entries are already sorted by priority. |
287 | 287 | foreach (\array_keys($cfg) as $class_name) { |
288 | 288 | if ($ex instanceof $class_name) { |
289 | - $result = $cfg[ $class_name ]; |
|
289 | + $result = $cfg[$class_name]; |
|
290 | 290 | break; |
291 | 291 | } |
292 | 292 | } |