@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | // Chop our parameter out of the original string |
101 | 101 | $str = |
102 | - substr($str, 0, $state['pos']). |
|
102 | + substr($str, 0, $state['pos']) . |
|
103 | 103 | substr($str, $state['pos'] + $len); |
104 | 104 | |
105 | 105 | // We need to move the position head back one after the chop |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | protected function prefixParentKeys($key, array $parent): string |
138 | 138 | { |
139 | 139 | return !empty($parent) ? |
140 | - $this->flattenKeys($parent).".$key" : $key; |
|
140 | + $this->flattenKeys($parent) . ".$key" : $key; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function add($keys) |
78 | 78 | { |
79 | - foreach ($this->expandKeys((array) $keys) as $key) { |
|
79 | + foreach ($this->expandKeys((array)$keys) as $key) { |
|
80 | 80 | if (!$this->has($key)) { |
81 | 81 | $this->keys[] = $key; |
82 | 82 | } |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function remove($keys) |
126 | 126 | { |
127 | - $keys = (array) $keys; // Cast all the things |
|
128 | - $this->keys = array_filter($this->keys(), function ($key) use ($keys) { |
|
127 | + $keys = (array)$keys; // Cast all the things |
|
128 | + $this->keys = array_filter($this->keys(), function($key) use ($keys) { |
|
129 | 129 | foreach ($keys as $remove) { |
130 | - if (preg_match('/^'.preg_quote($remove, '/').'(\..+)?$/', $key)) { |
|
130 | + if (preg_match('/^' . preg_quote($remove, '/') . '(\..+)?$/', $key)) { |
|
131 | 131 | // Keys and descendant keys will be removed |
132 | 132 | return false; |
133 | 133 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function baseKeys(): array |
146 | 146 | { |
147 | - return \array_values(\array_filter($this->keys(), function ($key) { |
|
147 | + return \array_values(\array_filter($this->keys(), function($key) { |
|
148 | 148 | return \strpos($key, '.') === false; |
149 | 149 | })); |
150 | 150 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | if (strpos($key, "{$parentKey}.") === 0) { |
265 | 265 | // Found a match, chop off the parent key |
266 | 266 | $keys[] = preg_replace( |
267 | - '/^'.preg_quote($parentKey.'.', '/').'/', // Starts with parent |
|
267 | + '/^' . preg_quote($parentKey . '.', '/') . '/', // Starts with parent |
|
268 | 268 | '', // Remove it |
269 | 269 | $key |
270 | 270 | ); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $settings['relation'] = []; |
102 | 102 | } |
103 | 103 | if (!isset($settings['method'])) { |
104 | - $settings['method'] = 'include'.StrHelper::studlyCase($includeKey); |
|
104 | + $settings['method'] = 'include' . StrHelper::studlyCase($includeKey); |
|
105 | 105 | } |
106 | 106 | if (!isset($settings['default'])) { |
107 | 107 | $settings['default'] = false; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getDefaultIncludes(): array |
122 | 122 | { |
123 | - return array_values(array_filter(array_keys($this->getCachedIncludeMap()), function ($includeKey) { |
|
123 | + return array_values(array_filter(array_keys($this->getCachedIncludeMap()), function($includeKey) { |
|
124 | 124 | return $this->getCachedIncludeMap()[$includeKey]['default']; |
125 | 125 | })); |
126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | public function getRelationships(): array |
134 | 134 | { |
135 | 135 | return array_column( |
136 | - array_map(function ($includeKey, $settings) { |
|
136 | + array_map(function($includeKey, $settings) { |
|
137 | 137 | return [$includeKey, $settings['relation']]; |
138 | 138 | }, array_keys($this->getCachedIncludeMap()), array_values($this->getCachedIncludeMap())), |
139 | 139 | 1, 0 |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function toObject(): \stdClass |
145 | 145 | { |
146 | - return (object) json_decode($this->toJson(), false); |
|
146 | + return (object)json_decode($this->toJson(), false); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | } elseif (\is_object($resource) && method_exists($resource, 'toArray')) { |
349 | 349 | $output = $resource->toArray(); |
350 | 350 | } else { |
351 | - throw new UnhandledResourceType('Unable to serialize resource of type '.\gettype($resource)); |
|
351 | + throw new UnhandledResourceType('Unable to serialize resource of type ' . \gettype($resource)); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | return $output; |
@@ -424,11 +424,11 @@ discard block |
||
424 | 424 | { |
425 | 425 | if ($transformer === null) { |
426 | 426 | // No transformation can be applied |
427 | - return (array) $item; |
|
427 | + return (array)$item; |
|
428 | 428 | } |
429 | 429 | if (\is_callable($transformer)) { |
430 | 430 | // Callable should simply return an array |
431 | - return (array) $transformer($item); |
|
431 | + return (array)$transformer($item); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | // Only these keys may be mapped |
@@ -438,12 +438,12 @@ discard block |
||
438 | 438 | $wantIncludeKeys = $includes->baseKeys() ?: $transformer->getDefaultIncludes(); |
439 | 439 | |
440 | 440 | // Find the keys that are declared in the $includes of the transformer |
441 | - $mappedIncludeKeys = array_filter($wantIncludeKeys, function ($includeKey) use ($availableIncludeKeys) { |
|
441 | + $mappedIncludeKeys = array_filter($wantIncludeKeys, function($includeKey) use ($availableIncludeKeys) { |
|
442 | 442 | return \in_array($includeKey, $availableIncludeKeys, true); |
443 | 443 | }); |
444 | 444 | |
445 | 445 | // We can consider our props anything that has not been mapped |
446 | - $filterProps = array_filter($wantIncludeKeys, function ($includeKey) use ($mappedIncludeKeys) { |
|
446 | + $filterProps = array_filter($wantIncludeKeys, function($includeKey) use ($mappedIncludeKeys) { |
|
447 | 447 | return !\in_array($includeKey, $mappedIncludeKeys, true); |
448 | 448 | }); |
449 | 449 | |
@@ -458,11 +458,11 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | // Get the base data from the transformation |
461 | - $data = (array) $transformer->transform($item); |
|
461 | + $data = (array)$transformer->transform($item); |
|
462 | 462 | |
463 | 463 | // Filter the sparse field-set |
464 | 464 | if (!empty($filterProps)) { |
465 | - $filteredData = array_filter($data, function ($key) use ($filterProps) { |
|
465 | + $filteredData = array_filter($data, function($key) use ($filterProps) { |
|
466 | 466 | return \in_array($key, $filterProps, true); |
467 | 467 | }, ARRAY_FILTER_USE_KEY); |
468 | 468 |
@@ -98,7 +98,7 @@ |
||
98 | 98 | 'current' => $cursor->getCurrent(), |
99 | 99 | 'prev' => $cursor->getPrev(), |
100 | 100 | 'next' => $cursor->getNext(), |
101 | - 'count' => (int) $cursor->getCount(), |
|
101 | + 'count' => (int)$cursor->getCount(), |
|
102 | 102 | ], |
103 | 103 | ]; |
104 | 104 | } |