@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public function remove($keys) |
| 120 | 120 | { |
| 121 | 121 | $keys = (array)$keys; // Cast all the things |
| 122 | - $this->keys = array_filter($this->keys(), function ($key) use ($keys) { |
|
| 122 | + $this->keys = array_filter($this->keys(), function($key) use ($keys) { |
|
| 123 | 123 | foreach ($keys as $remove) { |
| 124 | 124 | if (preg_match('/^' . preg_quote($key, '/') . '(\..+)?$/', $remove)) { |
| 125 | 125 | // Keys and descendant keys will be removed |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function baseKeys(): array |
| 139 | 139 | { |
| 140 | - return \array_values(\array_filter($this->keys(), function ($key) { |
|
| 140 | + return \array_values(\array_filter($this->keys(), function($key) { |
|
| 141 | 141 | return \strpos($key, '.') === false; |
| 142 | 142 | })); |
| 143 | 143 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | if (strpos($key, "{$parentKey}.") === 0) { |
| 236 | 236 | // Found a match, chop off the parent key |
| 237 | 237 | $keys[] = preg_replace( |
| 238 | - '/^' . preg_quote($parentKey.'.', '/') . '/', // Starts with parent |
|
| 238 | + '/^' . preg_quote($parentKey . '.', '/') . '/', // Starts with parent |
|
| 239 | 239 | '', // Remove it |
| 240 | 240 | $key |
| 241 | 241 | ); |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | // Well, if we have a buffer, then that's our parent, if we don't |
| 80 | 80 | // we will use the parent we saved when we popped the last parent state. |
| 81 | 81 | $parentKey = !empty($state['buffer']) ? |
| 82 | - $this->prefixParentKeys($state['buffer'], $state['parent']) : |
|
| 83 | - $this->flattenKeys($state['prevParent']); |
|
| 82 | + $this->prefixParentKeys($state['buffer'], $state['parent']) : $this->flattenKeys($state['prevParent']); |
|
| 84 | 83 | |
| 85 | 84 | if (preg_match('/^:(\w+)\(([^)]+)\)/', substr($str, $state['pos']), $match)) { |
| 86 | 85 | // We have a match |
@@ -133,8 +132,7 @@ discard block |
||
| 133 | 132 | protected function prefixParentKeys($key, array $parent): string |
| 134 | 133 | { |
| 135 | 134 | return !empty($parent) ? |
| 136 | - $this->flattenKeys($parent) . ".$key" : |
|
| 137 | - $key; |
|
| 135 | + $this->flattenKeys($parent) . ".$key" : $key; |
|
| 138 | 136 | } |
| 139 | 137 | |
| 140 | 138 | /** |
@@ -301,12 +301,12 @@ discard block |
||
| 301 | 301 | $wantIncludeKeys = $includes->baseKeys() ?: $transformer->getDefaultIncludes(); |
| 302 | 302 | |
| 303 | 303 | // Find the keys that are declared in the $includes of the transformer |
| 304 | - $mappedIncludeKeys = array_filter($wantIncludeKeys, function ($includeKey) use ($availableIncludeKeys) { |
|
| 304 | + $mappedIncludeKeys = array_filter($wantIncludeKeys, function($includeKey) use ($availableIncludeKeys) { |
|
| 305 | 305 | return \in_array($includeKey, $availableIncludeKeys, true); |
| 306 | 306 | }); |
| 307 | 307 | |
| 308 | 308 | // We can consider our props anything to not be mapped |
| 309 | - $filterProps = array_filter($wantIncludeKeys, function ($includeKey) use ($mappedIncludeKeys) { |
|
| 309 | + $filterProps = array_filter($wantIncludeKeys, function($includeKey) use ($mappedIncludeKeys) { |
|
| 310 | 310 | return !\in_array($includeKey, $mappedIncludeKeys, true); |
| 311 | 311 | }); |
| 312 | 312 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | // Filter the sparse field-set |
| 327 | 327 | if (!empty($filterProps)) { |
| 328 | - $filteredData = array_filter($data, function ($key) use ($filterProps) { |
|
| 328 | + $filteredData = array_filter($data, function($key) use ($filterProps) { |
|
| 329 | 329 | return \in_array($key, $filterProps, true); |
| 330 | 330 | }, ARRAY_FILTER_USE_KEY); |
| 331 | 331 | |
@@ -75,8 +75,7 @@ discard block |
||
| 75 | 75 | break; |
| 76 | 76 | case 'relation': |
| 77 | 77 | $settings['relation'] = !empty($val) ? |
| 78 | - preg_split('/s*,\s*/', $val) : |
|
| 79 | - [$includeKey]; |
|
| 78 | + preg_split('/s*,\s*/', $val) : [$includeKey]; |
|
| 80 | 79 | break; |
| 81 | 80 | case 'method': |
| 82 | 81 | if (!empty($val)) { |
@@ -110,7 +109,7 @@ discard block |
||
| 110 | 109 | */ |
| 111 | 110 | public function getDefaultIncludes(): array |
| 112 | 111 | { |
| 113 | - return array_filter(array_keys($this->getCachedIncludeMap()), function ($includeKey) { |
|
| 112 | + return array_filter(array_keys($this->getCachedIncludeMap()), function($includeKey) { |
|
| 114 | 113 | return $this->getCachedIncludeMap()[$includeKey]['default']; |
| 115 | 114 | }); |
| 116 | 115 | } |
@@ -121,7 +120,7 @@ discard block |
||
| 121 | 120 | public function getRelationships(): array |
| 122 | 121 | { |
| 123 | 122 | // TODO: not sure if this works |
| 124 | - return array_flatten(array_map(function ($includeKey, $settings) { |
|
| 123 | + return array_flatten(array_map(function($includeKey, $settings) { |
|
| 125 | 124 | return [$includeKey => $settings['relation']]; |
| 126 | 125 | }, array_keys($this->getCachedIncludeMap()), array_values($this->getCachedIncludeMap()))); |
| 127 | 126 | } |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | // Build the output by recursively transforming each resource |
| 49 | 49 | return $scope->isCollection() ? |
| 50 | - $this->serializeCollection($scope) : |
|
| 51 | - $this->serializeItem($scope); |
|
| 50 | + $this->serializeCollection($scope) : $this->serializeItem($scope); |
|
| 52 | 51 | } |
| 53 | 52 | |
| 54 | 53 | protected function loadRelations(ResourceInterface $resource) |
@@ -60,7 +59,7 @@ discard block |
||
| 60 | 59 | |
| 61 | 60 | protected function serializeCollection(Scope $scope) |
| 62 | 61 | { |
| 63 | - $items = array_map(function ($data) use ($scope) { |
|
| 62 | + $items = array_map(function($data) use ($scope) { |
|
| 64 | 63 | |
| 65 | 64 | $scope = new Scope( |
| 66 | 65 | new Item( |
@@ -142,7 +141,7 @@ discard block |
||
| 142 | 141 | // TODO: This is probably the wrong place for this as we might filter out our inclusions? |
| 143 | 142 | $wantProps = $defaultProps; |
| 144 | 143 | if (!empty($wantProps)) { |
| 145 | - $data = array_filter($data, function ($key) use ($wantProps) { |
|
| 144 | + $data = array_filter($data, function($key) use ($wantProps) { |
|
| 146 | 145 | return \in_array($key, $wantProps, true); |
| 147 | 146 | }, ARRAY_FILTER_USE_KEY); |
| 148 | 147 | } |