@@ -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 | ); |
@@ -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 | } |
@@ -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() |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | $relation = $this->get('relation', []); |
12 | 12 | if (!\is_array($relation)) { |
13 | - $relation = (array) preg_split('/\s*,\s*', $relation); |
|
13 | + $relation = (array)preg_split('/\s*,\s*', $relation); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | return $relation; |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | switch ($propDefinition->type()) { |
149 | 149 | case 'int': |
150 | 150 | case 'integer': |
151 | - return (int) $value; |
|
151 | + return (int)$value; |
|
152 | 152 | case 'real': |
153 | 153 | case 'float': |
154 | 154 | case 'double': |
155 | - return (float) $value; |
|
155 | + return (float)$value; |
|
156 | 156 | case 'string': |
157 | - return (string) $value; |
|
157 | + return (string)$value; |
|
158 | 158 | case 'bool': |
159 | 159 | case 'boolean': |
160 | - return (bool) $value; |
|
160 | + return (bool)$value; |
|
161 | 161 | case 'array': |
162 | - return (array) $value; |
|
162 | + return (array)$value; |
|
163 | 163 | case 'date': |
164 | 164 | return $this->formatDate($value, $propDefinition); |
165 | 165 | case 'datetime': |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | // As a final attempt, try to locate a matching method on the class that |
176 | 176 | // is prefixed with 'format'. |
177 | - $method = 'format'.StrHelper::studlyCase($propDefinition->type()); |
|
177 | + $method = 'format' . StrHelper::studlyCase($propDefinition->type()); |
|
178 | 178 | if (method_exists($this, $method)) { |
179 | 179 | return $this->$method($value, $propDefinition); |
180 | 180 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function toObject(): \stdClass |
156 | 156 | { |
157 | - return (object) json_decode($this->toJson()); |
|
157 | + return (object)json_decode($this->toJson()); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | } elseif (\is_object($resource) && method_exists($resource, 'toArray')) { |
373 | 373 | $output = $resource->toArray(); |
374 | 374 | } else { |
375 | - throw new UnhandledResourceType('Unable to serialize resource of type '.\gettype($resource)); |
|
375 | + throw new UnhandledResourceType('Unable to serialize resource of type ' . \gettype($resource)); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | return $output; |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | { |
452 | 452 | if ($transformer === null) { |
453 | 453 | // No transformation can be applied. |
454 | - return (array) $item; |
|
454 | + return (array)$item; |
|
455 | 455 | } |
456 | 456 | if (\is_callable($transformer)) { |
457 | 457 | // Callable should simply return an array. |
458 | - return (array) $transformer($item); |
|
458 | + return (array)$transformer($item); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | // Only these keys may be mapped |
@@ -465,12 +465,12 @@ discard block |
||
465 | 465 | $wantIncludeKeys = $includes->baseKeys() ?: $transformer->getDefaultIncludes(); |
466 | 466 | |
467 | 467 | // Find the keys that are declared in the $includes of the transformer |
468 | - $mappedIncludeKeys = array_filter($wantIncludeKeys, function ($includeKey) use ($availableIncludeKeys) { |
|
468 | + $mappedIncludeKeys = array_filter($wantIncludeKeys, function($includeKey) use ($availableIncludeKeys) { |
|
469 | 469 | return \in_array($includeKey, $availableIncludeKeys, true); |
470 | 470 | }); |
471 | 471 | |
472 | 472 | // We can consider our props anything that has not been mapped. |
473 | - $filterProps = array_filter($wantIncludeKeys, function ($includeKey) use ($mappedIncludeKeys) { |
|
473 | + $filterProps = array_filter($wantIncludeKeys, function($includeKey) use ($mappedIncludeKeys) { |
|
474 | 474 | return !\in_array($includeKey, $mappedIncludeKeys, true); |
475 | 475 | }); |
476 | 476 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | |
490 | 490 | // Filter the sparse field-set |
491 | 491 | if (!empty($filterProps)) { |
492 | - $filteredData = array_filter($data, function ($key) use ($filterProps) { |
|
492 | + $filteredData = array_filter($data, function($key) use ($filterProps) { |
|
493 | 493 | return \in_array($key, $filterProps, true); |
494 | 494 | }, ARRAY_FILTER_USE_KEY); |
495 | 495 |