@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $result = null; |
| 62 | 62 | |
| 63 | 63 | $type = \gettype($data); |
| 64 | - $result = $this->primitives[ $type ] ?? null; |
|
| 64 | + $result = $this->primitives[$type] ?? null; |
|
| 65 | 65 | if ($result === null) { |
| 66 | 66 | throw new \InvalidArgumentException(sprintf('No data conversion mapping configured for "%s" primitive.', $type)); |
| 67 | 67 | } |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | $cls = \get_class($data); |
| 94 | 94 | if (\is_string($cls)) { |
| 95 | 95 | if (\array_key_exists($cls, $this->classes)) { |
| 96 | - $result = $this->classes[ $cls ]; |
|
| 96 | + $result = $this->classes[$cls]; |
|
| 97 | 97 | $debug_result = 'exact config match'; |
| 98 | 98 | } else { |
| 99 | 99 | // no exact match, then lets try with `instanceof` |
| 100 | 100 | foreach (\array_keys($this->classes) as $class_name) { |
| 101 | 101 | if ($data instanceof $class_name) { |
| 102 | - $result = $this->classes[ $class_name ]; |
|
| 102 | + $result = $this->classes[$class_name]; |
|
| 103 | 103 | $debug_result = "subclass of {$class_name}"; |
| 104 | 104 | break; |
| 105 | 105 | } |
@@ -146,22 +146,22 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | if ($result === null && \is_object($data)) { |
| 148 | 148 | $cfg = $this->getClassMappingConfigOrThrow($data); |
| 149 | - $worker = new $cfg[ ResponseBuilder::KEY_HANDLER ](); |
|
| 150 | - $result = [$cfg[ ResponseBuilder::KEY_KEY ] => $worker->convert($data, $cfg)]; |
|
| 149 | + $worker = new $cfg[ResponseBuilder::KEY_HANDLER](); |
|
| 150 | + $result = [$cfg[ResponseBuilder::KEY_KEY] => $worker->convert($data, $cfg)]; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if ($result === null && \is_array($data)) { |
| 154 | 154 | $cfg = $this->getPrimitiveMappingConfigOrThrow($data); |
| 155 | 155 | |
| 156 | - if ($this->hasNonNumericKeys($data)){ |
|
| 156 | + if ($this->hasNonNumericKeys($data)) { |
|
| 157 | 157 | $result = $this->convertArray($data); |
| 158 | 158 | } else { |
| 159 | - $result = [$cfg[ ResponseBuilder::KEY_KEY ] => $this->convertArray($data)]; |
|
| 159 | + $result = [$cfg[ResponseBuilder::KEY_KEY] => $this->convertArray($data)]; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( \is_bool($data) || \is_float($data) || \is_int($data) || \is_string($data)) { |
|
| 164 | - $result = [$this->getPrimitiveMappingConfigOrThrow($data)[ ResponseBuilder::KEY_KEY ] => $data]; |
|
| 163 | + if (\is_bool($data) || \is_float($data) || \is_int($data) || \is_string($data)) { |
|
| 164 | + $result = [$this->getPrimitiveMappingConfigOrThrow($data)[ResponseBuilder::KEY_KEY] => $data]; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | return $result; |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | foreach ($data as $key => $val) { |
| 220 | 220 | if (\is_array($val)) { |
| 221 | - $data[ $key ] = $this->convertArray($val); |
|
| 221 | + $data[$key] = $this->convertArray($val); |
|
| 222 | 222 | } elseif (\is_object($val)) { |
| 223 | 223 | $cfg = $this->getClassMappingConfigOrThrow($val); |
| 224 | - $worker = new $cfg[ ResponseBuilder::KEY_HANDLER ](); |
|
| 224 | + $worker = new $cfg[ResponseBuilder::KEY_HANDLER](); |
|
| 225 | 225 | $converted_data = $worker->convert($val, $cfg); |
| 226 | - $data[ $key ] = $converted_data; |
|
| 226 | + $data[$key] = $converted_data; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |