@@ -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 | } |
@@ -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 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $settings['relation'] = []; |
| 111 | 111 | } |
| 112 | 112 | if (!isset($settings['method'])) { |
| 113 | - $settings['method'] = 'include'.StrHelper::studlyCase($includeKey); |
|
| 113 | + $settings['method'] = 'include' . StrHelper::studlyCase($includeKey); |
|
| 114 | 114 | } |
| 115 | 115 | if (!isset($settings['default'])) { |
| 116 | 116 | $settings['default'] = false; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function getDefaultIncludes(): array |
| 134 | 134 | { |
| 135 | - return array_values(array_filter(array_keys($this->getIncludeMap()), function ($includeKey) { |
|
| 135 | + return array_values(array_filter(array_keys($this->getIncludeMap()), function($includeKey) { |
|
| 136 | 136 | return $this->getIncludeMap()[$includeKey]['default']; |
| 137 | 137 | })); |
| 138 | 138 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function getRelationships(): array |
| 146 | 146 | { |
| 147 | 147 | return array_column( |
| 148 | - array_filter(array_map(function ($includeKey, $settings) { |
|
| 148 | + array_filter(array_map(function($includeKey, $settings) { |
|
| 149 | 149 | return $settings['relation'] ? [$includeKey, $settings['relation']] : null; |
| 150 | 150 | }, array_keys($this->getIncludeMap()), array_values($this->getIncludeMap()))), |
| 151 | 151 | 1, 0 |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | { |
| 208 | 208 | if (method_exists($this, 'transform')) { |
| 209 | 209 | // Transformer provides a 'transform' method |
| 210 | - return (array) $this->transform($data); |
|
| 210 | + return (array)$this->transform($data); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // Otherwise, use the withProps method which calls getProps() |
@@ -154,7 +154,7 @@ |
||
| 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 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | { |
| 150 | 150 | $availableIncludeKeys = $this->availableIncludeKeys(); |
| 151 | 151 | |
| 152 | - return array_filter($this->includeKeys(), function ($includeKey) use ($availableIncludeKeys) { |
|
| 152 | + return array_filter($this->includeKeys(), function($includeKey) use ($availableIncludeKeys) { |
|
| 153 | 153 | return \in_array($includeKey, $availableIncludeKeys, true); |
| 154 | 154 | }); |
| 155 | 155 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | // We can consider our props anything that has not been mapped. |
| 181 | 181 | $resolvedIncludeKeys = $this->resolvedIncludeKeys(); |
| 182 | - $keys = array_filter($this->includeKeys(), function ($includeKey) use ($resolvedIncludeKeys) { |
|
| 182 | + $keys = array_filter($this->includeKeys(), function($includeKey) use ($resolvedIncludeKeys) { |
|
| 183 | 183 | return !\in_array($includeKey, $resolvedIncludeKeys, true); |
| 184 | 184 | }); |
| 185 | 185 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | // defined that we want. |
| 248 | 248 | $filterProps = $this->filterProps(); |
| 249 | 249 | if (!empty($filterProps)) { |
| 250 | - $filteredData = array_filter($data, function ($key) use ($filterProps) { |
|
| 250 | + $filteredData = array_filter($data, function($key) use ($filterProps) { |
|
| 251 | 251 | return \in_array($key, $filterProps, true); |
| 252 | 252 | }, ARRAY_FILTER_USE_KEY); |
| 253 | 253 | |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | return $resource->toArray(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - throw new UnhandledResourceType('Unable to serialize resource of type '.\gettype($resource)); |
|
| 62 | + throw new UnhandledResourceType('Unable to serialize resource of type ' . \gettype($resource)); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Try to resolve a transformer for a resource that does not have one assigned. |