@@ -11,7 +11,7 @@ |
||
| 11 | 11 | |
| 12 | 12 | public static function snakeCase($str) |
| 13 | 13 | { |
| 14 | - if (! ctype_lower($str)) { |
|
| 14 | + if (!ctype_lower($str)) { |
|
| 15 | 15 | $str = preg_replace('/\s+/u', '', ucwords($str)); |
| 16 | 16 | $str = preg_replace('/(.)(?=[A-Z])/u', '$1_', $str); |
| 17 | 17 | $str = preg_replace('/\W+/', '_', $str); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $settings['relation'] = []; |
| 105 | 105 | } |
| 106 | 106 | if (!isset($settings['method'])) { |
| 107 | - $settings['method'] = 'include'.StrHelper::studlyCase($includeKey); |
|
| 107 | + $settings['method'] = 'include' . StrHelper::studlyCase($includeKey); |
|
| 108 | 108 | } |
| 109 | 109 | if (!isset($settings['default'])) { |
| 110 | 110 | $settings['default'] = false; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function getDefaultIncludes(): array |
| 125 | 125 | { |
| 126 | - return array_values(array_filter(array_keys($this->getCachedIncludeMap()), function ($includeKey) { |
|
| 126 | + return array_values(array_filter(array_keys($this->getCachedIncludeMap()), function($includeKey) { |
|
| 127 | 127 | return $this->getCachedIncludeMap()[$includeKey]['default']; |
| 128 | 128 | })); |
| 129 | 129 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | public function getRelationships(): array |
| 137 | 137 | { |
| 138 | 138 | return array_column( |
| 139 | - array_filter(array_map(function ($includeKey, $settings) { |
|
| 139 | + array_filter(array_map(function($includeKey, $settings) { |
|
| 140 | 140 | return $settings['relation'] ? [$includeKey, $settings['relation']] : null; |
| 141 | 141 | }, array_keys($this->getCachedIncludeMap()), array_values($this->getCachedIncludeMap()))), |
| 142 | 142 | 1, 0 |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | if (method_exists($this, 'transform')) { |
| 199 | 199 | // Transformer provides a 'transform' method |
| 200 | - return (array) $this->transform($data); |
|
| 200 | + return (array)$this->transform($data); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Otherwise, use the withProps method which calls getProps() |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function toObject(): \stdClass |
| 146 | 146 | { |
| 147 | - return (object) json_decode($this->toJson(), false); |
|
| 147 | + return (object)json_decode($this->toJson(), false); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | } elseif (\is_object($resource) && method_exists($resource, 'toArray')) { |
| 350 | 350 | $output = $resource->toArray(); |
| 351 | 351 | } else { |
| 352 | - throw new UnhandledResourceType('Unable to serialize resource of type '.\gettype($resource)); |
|
| 352 | + throw new UnhandledResourceType('Unable to serialize resource of type ' . \gettype($resource)); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | return $output; |
@@ -425,11 +425,11 @@ discard block |
||
| 425 | 425 | { |
| 426 | 426 | if ($transformer === null) { |
| 427 | 427 | // No transformation can be applied. |
| 428 | - return (array) $item; |
|
| 428 | + return (array)$item; |
|
| 429 | 429 | } |
| 430 | 430 | if (\is_callable($transformer)) { |
| 431 | 431 | // Callable should simply return an array. |
| 432 | - return (array) $transformer($item); |
|
| 432 | + return (array)$transformer($item); |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // Only these keys may be mapped |
@@ -439,12 +439,12 @@ discard block |
||
| 439 | 439 | $wantIncludeKeys = $includes->baseKeys() ?: $transformer->getDefaultIncludes(); |
| 440 | 440 | |
| 441 | 441 | // Find the keys that are declared in the $includes of the transformer |
| 442 | - $mappedIncludeKeys = array_filter($wantIncludeKeys, function ($includeKey) use ($availableIncludeKeys) { |
|
| 442 | + $mappedIncludeKeys = array_filter($wantIncludeKeys, function($includeKey) use ($availableIncludeKeys) { |
|
| 443 | 443 | return \in_array($includeKey, $availableIncludeKeys, true); |
| 444 | 444 | }); |
| 445 | 445 | |
| 446 | 446 | // We can consider our props anything that has not been mapped. |
| 447 | - $filterProps = array_filter($wantIncludeKeys, function ($includeKey) use ($mappedIncludeKeys) { |
|
| 447 | + $filterProps = array_filter($wantIncludeKeys, function($includeKey) use ($mappedIncludeKeys) { |
|
| 448 | 448 | return !\in_array($includeKey, $mappedIncludeKeys, true); |
| 449 | 449 | }); |
| 450 | 450 | |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | // Filter the sparse field-set |
| 465 | 465 | if (!empty($filterProps)) { |
| 466 | - $filteredData = array_filter($data, function ($key) use ($filterProps) { |
|
| 466 | + $filteredData = array_filter($data, function($key) use ($filterProps) { |
|
| 467 | 467 | return \in_array($key, $filterProps, true); |
| 468 | 468 | }, ARRAY_FILTER_USE_KEY); |
| 469 | 469 | |