@@ -244,7 +244,7 @@ |
||
244 | 244 | /** |
245 | 245 | * @param Number $value |
246 | 246 | * @return bool |
247 | - * @throws InvalidArgumentException If neither int or float passed. |
|
247 | + * @throws InvalidArgumentException If neither int or float passed. |
|
248 | 248 | */ |
249 | 249 | return function ($value) use ($factor): bool { |
250 | 250 | if (! C\isNumber($value)) { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param int|null $value |
47 | 47 | * @return Closure(int|null):(Closure|int)|int |
48 | 48 | */ |
49 | - return function (?int $value = null) use ($initial) { |
|
49 | + return function(?int $value = null) use ($initial) { |
|
50 | 50 | if ($value) { |
51 | 51 | $initial += $value; |
52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param float|null $value |
67 | 67 | * @return Closure(float|null):(Closure|float)|float |
68 | 68 | */ |
69 | - return function (?float $value = null) use ($initial) { |
|
69 | + return function(?float $value = null) use ($initial) { |
|
70 | 70 | if ($value) { |
71 | 71 | $initial += $value; |
72 | 72 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function sum($initial = 0): Closure |
85 | 85 | { |
86 | - if (! C\isNumber($initial)) { |
|
86 | + if (!C\isNumber($initial)) { |
|
87 | 87 | throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
88 | 88 | } |
89 | 89 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param Number $value |
92 | 92 | * @return int|float |
93 | 93 | */ |
94 | - return function ($value) use ($initial) { |
|
94 | + return function($value) use ($initial) { |
|
95 | 95 | return $initial + $value; |
96 | 96 | }; |
97 | 97 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | function subtract($initial = 0): Closure |
108 | 108 | { |
109 | - if (! C\isNumber($initial)) { |
|
109 | + if (!C\isNumber($initial)) { |
|
110 | 110 | throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
111 | 111 | } |
112 | 112 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param Number $value |
115 | 115 | * @return int|float |
116 | 116 | */ |
117 | - return function ($value) use ($initial) { |
|
117 | + return function($value) use ($initial) { |
|
118 | 118 | return $value - $initial; |
119 | 119 | }; |
120 | 120 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function multiply($initial = 1): Closure |
131 | 131 | { |
132 | - if (! C\isNumber($initial)) { |
|
132 | + if (!C\isNumber($initial)) { |
|
133 | 133 | throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
134 | 134 | } |
135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param Number $value |
138 | 138 | * @return Number |
139 | 139 | */ |
140 | - return function ($value) use ($initial) { |
|
140 | + return function($value) use ($initial) { |
|
141 | 141 | return $value * $initial; |
142 | 142 | }; |
143 | 143 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | function divideBy($divisor = 1): Closure |
154 | 154 | { |
155 | - if (! C\isNumber($divisor)) { |
|
155 | + if (!C\isNumber($divisor)) { |
|
156 | 156 | throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
157 | 157 | } |
158 | 158 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param float $value |
161 | 161 | * @return float |
162 | 162 | */ |
163 | - return function ($value) use ($divisor): float { |
|
163 | + return function($value) use ($divisor): float { |
|
164 | 164 | return $value / $divisor; |
165 | 165 | }; |
166 | 166 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | function divideInto($dividend = 1): Closure |
175 | 175 | { |
176 | - if (! C\isNumber($dividend)) { |
|
176 | + if (!C\isNumber($dividend)) { |
|
177 | 177 | throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
178 | 178 | } |
179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param float $value |
182 | 182 | * @return float |
183 | 183 | */ |
184 | - return function ($value) use ($dividend): float { |
|
184 | + return function($value) use ($dividend): float { |
|
185 | 185 | return $dividend / $value; |
186 | 186 | }; |
187 | 187 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | function remainderBy($divisor = 1): Closure |
196 | 196 | { |
197 | - if (! C\isNumber($divisor)) { |
|
197 | + if (!C\isNumber($divisor)) { |
|
198 | 198 | throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
199 | 199 | } |
200 | 200 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param float $value |
203 | 203 | * @return float |
204 | 204 | */ |
205 | - return function ($value) use ($divisor): float { |
|
205 | + return function($value) use ($divisor): float { |
|
206 | 206 | return $value % $divisor; |
207 | 207 | }; |
208 | 208 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function remainderInto($dividend = 1): Closure |
217 | 217 | { |
218 | - if (! C\isNumber($dividend)) { |
|
218 | + if (!C\isNumber($dividend)) { |
|
219 | 219 | throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
220 | 220 | } |
221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @param float $value |
224 | 224 | * @return float |
225 | 225 | */ |
226 | - return function ($value) use ($dividend): float { |
|
226 | + return function($value) use ($dividend): float { |
|
227 | 227 | return $dividend % $value; |
228 | 228 | }; |
229 | 229 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | function isFactorOf($factor): Closure |
239 | 239 | { |
240 | - if (! C\isNumber($factor)) { |
|
240 | + if (!C\isNumber($factor)) { |
|
241 | 241 | throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
242 | 242 | } |
243 | 243 | |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | * @return bool |
247 | 247 | * @throws InvalidArgumentException If neither int or float passed. |
248 | 248 | */ |
249 | - return function ($value) use ($factor): bool { |
|
250 | - if (! C\isNumber($value)) { |
|
249 | + return function($value) use ($factor): bool { |
|
250 | + if (!C\isNumber($value)) { |
|
251 | 251 | throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
252 | 252 | } |
253 | 253 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | function round($precision = 1): Closure |
271 | 271 | { |
272 | - if (! C\isNumber($precision)) { |
|
272 | + if (!C\isNumber($precision)) { |
|
273 | 273 | throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
274 | 274 | } |
275 | 275 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param Number $value |
278 | 278 | * @return float |
279 | 279 | */ |
280 | - return function ($value) use ($precision): float { |
|
281 | - if (! C\isNumber($value)) { |
|
280 | + return function($value) use ($precision): float { |
|
281 | + if (!C\isNumber($value)) { |
|
282 | 282 | throw new \InvalidArgumentException("Num\\round() only accepts a valid Number ( Int|Float -> Float )"); |
283 | 283 | } |
284 | 284 | return \round(\floatval($value), $precision); |
@@ -264,7 +264,7 @@ |
||
264 | 264 | * Only works for public or dynamic properties. |
265 | 265 | * |
266 | 266 | * @param array<string,mixed>|ArrayObject<string,mixed>|object $store |
267 | - * @param string $property The property key. |
|
267 | + * @param string $property The property key. |
|
268 | 268 | * @return Closure(mixed):(array<string,mixed>|ArrayObject<string,mixed>|object) |
269 | 269 | */ |
270 | 270 | function setProperty($store, string $property): Closure |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param mixed The value passed into the functions |
49 | 49 | * @return mixed The final result. |
50 | 50 | */ |
51 | - return function ($e) use ($callables) { |
|
51 | + return function($e) use ($callables) { |
|
52 | 52 | foreach ($callables as $callable) { |
53 | 53 | $e = $callable($e); |
54 | 54 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param mixed The value passed into the functions |
70 | 70 | * @return mixed The final result. |
71 | 71 | */ |
72 | - return function ($e) use ($callables) { |
|
72 | + return function($e) use ($callables) { |
|
73 | 73 | foreach (\array_reverse($callables) as $callable) { |
74 | 74 | $e = $callable($e); |
75 | 75 | } |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | * @param mixed The value passed into the functions |
91 | 91 | * @return mixed|null The final result or null. |
92 | 92 | */ |
93 | - return function ($e) use ($callables) { |
|
93 | + return function($e) use ($callables) { |
|
94 | 94 | foreach ($callables as $callable) { |
95 | - if (! is_null($e)) { |
|
95 | + if (!is_null($e)) { |
|
96 | 96 | $e = $callable($e); |
97 | 97 | } |
98 | 98 | } |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | * @param mixed $e The value being passed through the functions. |
116 | 116 | * @return mixed The final result. |
117 | 117 | */ |
118 | - return function ($e) use ($validator, $callables) { |
|
118 | + return function($e) use ($validator, $callables) { |
|
119 | 119 | foreach ($callables as $callable) { |
120 | 120 | // If invalid, abort and return null |
121 | - if (! $validator($e)) { |
|
121 | + if (!$validator($e)) { |
|
122 | 122 | return null; |
123 | 123 | } |
124 | 124 | // Run through callable. |
125 | 125 | $e = $callable($e); |
126 | 126 | |
127 | 127 | // Check results and bail if invalid type. |
128 | - if (! $validator($e)) { |
|
128 | + if (!$validator($e)) { |
|
129 | 129 | return null; |
130 | 130 | } |
131 | 131 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | * @param mixed $data The array or object to attempt to get param. |
172 | 172 | * @return mixed|null |
173 | 173 | */ |
174 | - return function ($data) use ($property) { |
|
174 | + return function($data) use ($property) { |
|
175 | 175 | if (is_array($data)) { |
176 | - return array_key_exists($property, $data) ? $data[ $property ] : null; |
|
176 | + return array_key_exists($property, $data) ? $data[$property] : null; |
|
177 | 177 | } elseif (is_object($data)) { |
178 | 178 | return property_exists($data, $property) ? $data->{$property} : null; |
179 | 179 | } else { |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param mixed[]|object $data The array or object to attempt to get param. |
197 | 197 | * @return mixed|null |
198 | 198 | */ |
199 | - return function ($data) use ($nodes) { |
|
199 | + return function($data) use ($nodes) { |
|
200 | 200 | foreach ($nodes as $node) { |
201 | 201 | $data = getProperty($node)($data); |
202 | 202 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param mixed $data The array or object to attempt to get param. |
222 | 222 | * @return mixed|null |
223 | 223 | */ |
224 | - return function ($data) use ($property): bool { |
|
224 | + return function($data) use ($property): bool { |
|
225 | 225 | if (is_array($data)) { |
226 | 226 | return array_key_exists($property, $data); |
227 | 227 | } elseif (is_object($data)) { |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @param mixed $data The array or object to attempt to get param. |
247 | 247 | * @return bool |
248 | 248 | */ |
249 | - return function ($data) use ($property, $value): bool { |
|
249 | + return function($data) use ($property, $value): bool { |
|
250 | 250 | return pipe( |
251 | 251 | $data, |
252 | 252 | getProperty($property), |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | { |
272 | 272 | |
273 | 273 | // If passed store is not an array or object, throw exception. |
274 | - if (! isArrayAccess($store) && ! is_object($store)) { |
|
274 | + if (!isArrayAccess($store) && !is_object($store)) { |
|
275 | 275 | throw new TypeError('Only objects or arrays can be constructed using setProperty.'); |
276 | 276 | } |
277 | 277 | |
@@ -279,10 +279,10 @@ discard block |
||
279 | 279 | * @param mixed $value The value to set to keu. |
280 | 280 | * @return array<string,mixed>|ArrayObject<string,mixed>|object The datastore. |
281 | 281 | */ |
282 | - return function ($value) use ($store, $property) { |
|
282 | + return function($value) use ($store, $property) { |
|
283 | 283 | if (isArrayAccess($store)) { |
284 | 284 | /** @phpstan-ignore-next-line */ |
285 | - $store[ $property ] = $value; |
|
285 | + $store[$property] = $value; |
|
286 | 286 | } else { |
287 | 287 | $store->{$property} = $value; |
288 | 288 | } |
@@ -305,8 +305,8 @@ discard block |
||
305 | 305 | * @param mixed $data The data to pass through the callable |
306 | 306 | * @return array |
307 | 307 | */ |
308 | - return function ($data) use ($key, $value): array { |
|
309 | - return array( $key => $value($data) ); |
|
308 | + return function($data) use ($key, $value): array { |
|
309 | + return array($key => $value($data)); |
|
310 | 310 | }; |
311 | 311 | } |
312 | 312 | |
@@ -323,12 +323,12 @@ discard block |
||
323 | 323 | * @param callable(mixed):mixed ...$encoders encodeProperty() functions. |
324 | 324 | * @return Closure |
325 | 325 | */ |
326 | - return function (...$encoders) use ($dataType): Closure { |
|
326 | + return function(...$encoders) use ($dataType): Closure { |
|
327 | 327 | /** |
328 | 328 | * @param mixed $data The data to pass through the encoders. |
329 | 329 | * @return array<string,mixed>|object The encoded object/array. |
330 | 330 | */ |
331 | - return function ($data) use ($dataType, $encoders) { |
|
331 | + return function($data) use ($dataType, $encoders) { |
|
332 | 332 | foreach ($encoders as $encoder) { |
333 | 333 | $key = array_keys($encoder($data))[0]; |
334 | 334 | // throw exception if key is int |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @param mixed ...$args |
356 | 356 | * @return mixed |
357 | 357 | */ |
358 | - return function (...$args) use ($fn) { |
|
358 | + return function(...$args) use ($fn) { |
|
359 | 359 | return $fn(...$args); |
360 | 360 | }; |
361 | 361 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @param mixed $ignored Any values can be passed and ignored. |
373 | 373 | * @return mixed |
374 | 374 | */ |
375 | - return function (...$ignored) use ($value) { |
|
375 | + return function(...$ignored) use ($value) { |
|
376 | 376 | return $value; |
377 | 377 | }; |
378 | 378 | } |
@@ -389,18 +389,18 @@ discard block |
||
389 | 389 | * @param object $object |
390 | 390 | * @return array<string, mixed> |
391 | 391 | */ |
392 | - return function ($object): array { |
|
392 | + return function($object): array { |
|
393 | 393 | |
394 | 394 | // If not object, return empty array. |
395 | - if (! is_object($object)) { |
|
395 | + if (!is_object($object)) { |
|
396 | 396 | return array(); |
397 | 397 | } |
398 | 398 | |
399 | 399 | $objectVars = get_object_vars($object); |
400 | 400 | return array_reduce( |
401 | 401 | array_keys($objectVars), |
402 | - function (array $array, $key) use ($objectVars): array { |
|
403 | - $array[ ltrim((string) $key, '_') ] = $objectVars[ $key ]; |
|
402 | + function(array $array, $key) use ($objectVars): array { |
|
403 | + $array[ltrim((string) $key, '_')] = $objectVars[$key]; |
|
404 | 404 | return $array; |
405 | 405 | }, |
406 | 406 | array() |