@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function appBooting(\Closure ...$callbacks): void |
38 | 38 | { |
39 | - foreach ($callbacks as $callback) { |
|
39 | + foreach ($callbacks as $callback){ |
|
40 | 40 | $this->bootingCallbacks[] = $callback; |
41 | 41 | } |
42 | 42 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function appBooted(\Closure ...$callbacks): void |
53 | 53 | { |
54 | - foreach ($callbacks as $callback) { |
|
54 | + foreach ($callbacks as $callback){ |
|
55 | 55 | $this->bootedCallbacks[] = $callback; |
56 | 56 | } |
57 | 57 | } |
@@ -89,29 +89,29 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function mapDirectories(array $directories): array |
91 | 91 | { |
92 | - if (!isset($directories['root'])) { |
|
92 | + if (!isset($directories['root'])){ |
|
93 | 93 | throw new BootException('Missing required directory `root`'); |
94 | 94 | } |
95 | 95 | |
96 | - if (!isset($directories['app'])) { |
|
97 | - $directories['app'] = $directories['root'] . '/app/'; |
|
96 | + if (!isset($directories['app'])){ |
|
97 | + $directories['app'] = $directories['root'].'/app/'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return \array_merge( |
101 | 101 | [ |
102 | 102 | // public root |
103 | - 'public' => $directories['root'] . '/public/', |
|
103 | + 'public' => $directories['root'].'/public/', |
|
104 | 104 | |
105 | 105 | // vendor libraries |
106 | - 'vendor' => $directories['root'] . '/vendor/', |
|
106 | + 'vendor' => $directories['root'].'/vendor/', |
|
107 | 107 | |
108 | 108 | // data directories |
109 | - 'runtime' => $directories['root'] . '/runtime/', |
|
110 | - 'cache' => $directories['root'] . '/runtime/cache/', |
|
109 | + 'runtime' => $directories['root'].'/runtime/', |
|
110 | + 'cache' => $directories['root'].'/runtime/cache/', |
|
111 | 111 | |
112 | 112 | // application directories |
113 | - 'config' => $directories['app'] . '/config/', |
|
114 | - 'resources' => $directories['app'] . '/resources/', |
|
113 | + 'config' => $directories['app'].'/config/', |
|
114 | + 'resources' => $directories['app'].'/resources/', |
|
115 | 115 | ], |
116 | 116 | $directories |
117 | 117 | ); |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function appBooting(\Closure ...$callbacks): void |
38 | 38 | { |
39 | - foreach ($callbacks as $callback) { |
|
39 | + foreach ($callbacks as $callback) |
|
40 | + { |
|
40 | 41 | $this->bootingCallbacks[] = $callback; |
41 | 42 | } |
42 | 43 | } |
@@ -51,7 +52,8 @@ discard block |
||
51 | 52 | */ |
52 | 53 | public function appBooted(\Closure ...$callbacks): void |
53 | 54 | { |
54 | - foreach ($callbacks as $callback) { |
|
55 | + foreach ($callbacks as $callback) |
|
56 | + { |
|
55 | 57 | $this->bootedCallbacks[] = $callback; |
56 | 58 | } |
57 | 59 | } |
@@ -89,11 +91,13 @@ discard block |
||
89 | 91 | */ |
90 | 92 | protected function mapDirectories(array $directories): array |
91 | 93 | { |
92 | - if (!isset($directories['root'])) { |
|
94 | + if (!isset($directories['root'])) |
|
95 | + { |
|
93 | 96 | throw new BootException('Missing required directory `root`'); |
94 | 97 | } |
95 | 98 | |
96 | - if (!isset($directories['app'])) { |
|
99 | + if (!isset($directories['app'])) |
|
100 | + { |
|
97 | 101 | $directories['app'] = $directories['root'] . '/app/'; |
98 | 102 | } |
99 | 103 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function __construct( |
21 | 21 | private readonly ContainerInterface $container, |
22 | 22 | private readonly FactoryInterface $factory |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
30 | 30 | { |
31 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
31 | + if (!$this->container->has(ServerRequestInterface::class)){ |
|
32 | 32 | throw new ScopeException('Unable to create paginator, no request scope found'); |
33 | 33 | } |
34 | 34 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | //Getting page number |
40 | 40 | $page = 0; |
41 | - if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) { |
|
41 | + if (!empty($query[$parameter]) && \is_scalar($query[$parameter])){ |
|
42 | 42 | $page = (int)$query[$parameter]; |
43 | 43 | } |
44 | 44 |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
30 | 30 | { |
31 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
31 | + if (!$this->container->has(ServerRequestInterface::class)) |
|
32 | + { |
|
32 | 33 | throw new ScopeException('Unable to create paginator, no request scope found'); |
33 | 34 | } |
34 | 35 | /** |
@@ -38,7 +39,8 @@ discard block |
||
38 | 39 | |
39 | 40 | //Getting page number |
40 | 41 | $page = 0; |
41 | - if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) { |
|
42 | + if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) |
|
43 | + { |
|
42 | 44 | $page = (int)$query[$parameter]; |
43 | 45 | } |
44 | 46 |
@@ -23,11 +23,11 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null) |
25 | 25 | { |
26 | - if (empty($code) && empty($this->code)) { |
|
26 | + if (empty($code) && empty($this->code)){ |
|
27 | 27 | $code = self::BAD_DATA; |
28 | 28 | } |
29 | 29 | |
30 | - if (empty($message)) { |
|
30 | + if (empty($message)){ |
|
31 | 31 | $message = \sprintf('Http Error - %s', $code); |
32 | 32 | } |
33 | 33 |
@@ -23,11 +23,13 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null) |
25 | 25 | { |
26 | - if (empty($code) && empty($this->code)) { |
|
26 | + if (empty($code) && empty($this->code)) |
|
27 | + { |
|
27 | 28 | $code = self::BAD_DATA; |
28 | 29 | } |
29 | 30 | |
30 | - if (empty($message)) { |
|
31 | + if (empty($message)) |
|
32 | + { |
|
31 | 33 | $message = \sprintf('Http Error - %s', $code); |
32 | 34 | } |
33 | 35 |
@@ -16,11 +16,11 @@ |
||
16 | 16 | */ |
17 | 17 | private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface |
18 | 18 | { |
19 | - if ($payload instanceof \JsonSerializable) { |
|
19 | + if ($payload instanceof \JsonSerializable){ |
|
20 | 20 | $payload = $payload->jsonSerialize(); |
21 | 21 | } |
22 | 22 | |
23 | - if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) { |
|
23 | + if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])){ |
|
24 | 24 | $code = $payload['status']; |
25 | 25 | } |
26 | 26 |
@@ -16,11 +16,13 @@ |
||
16 | 16 | */ |
17 | 17 | private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface |
18 | 18 | { |
19 | - if ($payload instanceof \JsonSerializable) { |
|
19 | + if ($payload instanceof \JsonSerializable) |
|
20 | + { |
|
20 | 21 | $payload = $payload->jsonSerialize(); |
21 | 22 | } |
22 | 23 | |
23 | - if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) { |
|
24 | + if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) |
|
25 | + { |
|
24 | 26 | $code = $payload['status']; |
25 | 27 | } |
26 | 28 |
@@ -12,6 +12,6 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | public readonly ServerRequestInterface $request, |
14 | 14 | public readonly MiddlewareInterface $middleware |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -12,6 +12,6 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | public readonly ServerRequestInterface $request, |
14 | 14 | public readonly ResponseInterface $response |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | { |
16 | 16 | public function __construct( |
17 | 17 | private readonly array $data, |
18 | - private readonly int|string $prefix = '' |
|
19 | - ) { |
|
18 | + private readonly int | string $prefix = '' |
|
19 | + ){ |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function __debugInfo(): array |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | public function all(): array |
33 | 33 | { |
34 | - try { |
|
34 | + try{ |
|
35 | 35 | return $this->dotGet(''); |
36 | - } catch (DotNotFoundException) { |
|
36 | + }catch (DotNotFoundException){ |
|
37 | 37 | return []; |
38 | 38 | } |
39 | 39 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function fetch(array $keys, bool $fill = false, mixed $filler = null): array |
53 | 53 | { |
54 | 54 | $result = \array_intersect_key($this->all(), \array_flip($keys)); |
55 | - if (!$fill) { |
|
55 | + if (!$fill){ |
|
56 | 56 | return $result; |
57 | 57 | } |
58 | 58 | |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * Check if field presented (can be empty) by it's name. Dot notation allowed. |
64 | 64 | */ |
65 | - public function has(int|string $name): bool |
|
65 | + public function has(int | string $name): bool |
|
66 | 66 | { |
67 | - try { |
|
67 | + try{ |
|
68 | 68 | $this->dotGet($name); |
69 | - } catch (DotNotFoundException) { |
|
69 | + }catch (DotNotFoundException){ |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | |
76 | 76 | public function offsetExists(mixed $offset): bool |
77 | 77 | { |
78 | - try { |
|
78 | + try{ |
|
79 | 79 | return !\is_null($this->dotGet($offset)); |
80 | - } catch (DotNotFoundException) { |
|
80 | + }catch (DotNotFoundException){ |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * Get property or return default value. Dot notation allowed. |
92 | 92 | */ |
93 | - public function get(int|string $name, mixed $default = null): mixed |
|
93 | + public function get(int | string $name, mixed $default = null): mixed |
|
94 | 94 | { |
95 | - try { |
|
95 | + try{ |
|
96 | 96 | return $this->dotGet($name); |
97 | - } catch (DotNotFoundException) { |
|
97 | + }catch (DotNotFoundException){ |
|
98 | 98 | return $default; |
99 | 99 | } |
100 | 100 | } |
@@ -120,20 +120,20 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @throws DotNotFoundException |
122 | 122 | */ |
123 | - private function dotGet(int|string $name): mixed |
|
123 | + private function dotGet(int | string $name): mixed |
|
124 | 124 | { |
125 | 125 | $data = $this->data; |
126 | 126 | |
127 | 127 | //Generating path relative to a given name and prefix |
128 | - $path = (empty($this->prefix) ? '' : $this->prefix . '.') . $name; |
|
129 | - if (empty($path)) { |
|
128 | + $path = (empty($this->prefix) ? '' : $this->prefix.'.').$name; |
|
129 | + if (empty($path)){ |
|
130 | 130 | return $data; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $path = \explode('.', \rtrim($path, '.')); |
134 | 134 | |
135 | - foreach ($path as $step) { |
|
136 | - if (!\is_array($data) || !\array_key_exists($step, $data)) { |
|
135 | + foreach ($path as $step){ |
|
136 | + if (!\is_array($data) || !\array_key_exists($step, $data)){ |
|
137 | 137 | throw new DotNotFoundException(\sprintf("Unable to find requested element '%s'.", $name)); |
138 | 138 | } |
139 | 139 |
@@ -31,9 +31,12 @@ discard block |
||
31 | 31 | |
32 | 32 | public function all(): array |
33 | 33 | { |
34 | - try { |
|
34 | + try |
|
35 | + { |
|
35 | 36 | return $this->dotGet(''); |
36 | - } catch (DotNotFoundException) { |
|
37 | + } |
|
38 | + catch (DotNotFoundException) |
|
39 | + { |
|
37 | 40 | return []; |
38 | 41 | } |
39 | 42 | } |
@@ -52,7 +55,8 @@ discard block |
||
52 | 55 | public function fetch(array $keys, bool $fill = false, mixed $filler = null): array |
53 | 56 | { |
54 | 57 | $result = \array_intersect_key($this->all(), \array_flip($keys)); |
55 | - if (!$fill) { |
|
58 | + if (!$fill) |
|
59 | + { |
|
56 | 60 | return $result; |
57 | 61 | } |
58 | 62 | |
@@ -64,9 +68,12 @@ discard block |
||
64 | 68 | */ |
65 | 69 | public function has(int|string $name): bool |
66 | 70 | { |
67 | - try { |
|
71 | + try |
|
72 | + { |
|
68 | 73 | $this->dotGet($name); |
69 | - } catch (DotNotFoundException) { |
|
74 | + } |
|
75 | + catch (DotNotFoundException) |
|
76 | + { |
|
70 | 77 | return false; |
71 | 78 | } |
72 | 79 | |
@@ -75,9 +82,12 @@ discard block |
||
75 | 82 | |
76 | 83 | public function offsetExists(mixed $offset): bool |
77 | 84 | { |
78 | - try { |
|
85 | + try |
|
86 | + { |
|
79 | 87 | return !\is_null($this->dotGet($offset)); |
80 | - } catch (DotNotFoundException) { |
|
88 | + } |
|
89 | + catch (DotNotFoundException) |
|
90 | + { |
|
81 | 91 | return false; |
82 | 92 | } |
83 | 93 | } |
@@ -92,9 +102,12 @@ discard block |
||
92 | 102 | */ |
93 | 103 | public function get(int|string $name, mixed $default = null): mixed |
94 | 104 | { |
95 | - try { |
|
105 | + try |
|
106 | + { |
|
96 | 107 | return $this->dotGet($name); |
97 | - } catch (DotNotFoundException) { |
|
108 | + } |
|
109 | + catch (DotNotFoundException) |
|
110 | + { |
|
98 | 111 | return $default; |
99 | 112 | } |
100 | 113 | } |
@@ -126,14 +139,17 @@ discard block |
||
126 | 139 | |
127 | 140 | //Generating path relative to a given name and prefix |
128 | 141 | $path = (empty($this->prefix) ? '' : $this->prefix . '.') . $name; |
129 | - if (empty($path)) { |
|
142 | + if (empty($path)) |
|
143 | + { |
|
130 | 144 | return $data; |
131 | 145 | } |
132 | 146 | |
133 | 147 | $path = \explode('.', \rtrim($path, '.')); |
134 | 148 | |
135 | - foreach ($path as $step) { |
|
136 | - if (!\is_array($data) || !\array_key_exists($step, $data)) { |
|
149 | + foreach ($path as $step) |
|
150 | + { |
|
151 | + if (!\is_array($data) || !\array_key_exists($step, $data)) |
|
152 | + { |
|
137 | 153 | throw new DotNotFoundException(\sprintf("Unable to find requested element '%s'.", $name)); |
138 | 154 | } |
139 | 155 |
@@ -146,10 +146,13 @@ discard block |
||
146 | 146 | { |
147 | 147 | $input = clone $this; |
148 | 148 | |
149 | - if ($add) { |
|
149 | + if ($add) |
|
150 | + { |
|
150 | 151 | $input->prefix .= '.' . $prefix; |
151 | 152 | $input->prefix = \trim($input->prefix, '.'); |
152 | - } else { |
|
153 | + } |
|
154 | + else |
|
155 | + { |
|
153 | 156 | $input->prefix = $prefix; |
154 | 157 | } |
155 | 158 | |
@@ -185,9 +188,12 @@ discard block |
||
185 | 188 | */ |
186 | 189 | public function request(): Request |
187 | 190 | { |
188 | - try { |
|
191 | + try |
|
192 | + { |
|
189 | 193 | $request = $this->container->get(Request::class); |
190 | - } catch (ContainerExceptionInterface $e) { |
|
194 | + } |
|
195 | + catch (ContainerExceptionInterface $e) |
|
196 | + { |
|
191 | 197 | throw new ScopeException( |
192 | 198 | 'Unable to get `ServerRequestInterface` in active container scope', |
193 | 199 | $e->getCode(), |
@@ -196,7 +202,8 @@ discard block |
||
196 | 202 | } |
197 | 203 | |
198 | 204 | // Flushing input state |
199 | - if ($this->request !== $request) { |
|
205 | + if ($this->request !== $request) |
|
206 | + { |
|
200 | 207 | $this->bags = []; |
201 | 208 | $this->request = $request; |
202 | 209 | } |
@@ -213,7 +220,8 @@ discard block |
||
213 | 220 | |
214 | 221 | $position = \strrpos($header, 'Bearer '); |
215 | 222 | |
216 | - if ($position !== false) { |
|
223 | + if ($position !== false) |
|
224 | + { |
|
217 | 225 | $header = \substr($header, $position + 7); |
218 | 226 | |
219 | 227 | return \str_contains($header, ',') |
@@ -267,16 +275,21 @@ discard block |
||
267 | 275 | public function isJsonExpected(bool $softMatch = false): bool |
268 | 276 | { |
269 | 277 | $acceptHeader = AcceptHeader::fromString($this->request()->getHeaderLine('Accept')); |
270 | - foreach ($this->jsonTypes as $jsonType) { |
|
271 | - if ($acceptHeader->has($jsonType)) { |
|
278 | + foreach ($this->jsonTypes as $jsonType) |
|
279 | + { |
|
280 | + if ($acceptHeader->has($jsonType)) |
|
281 | + { |
|
272 | 282 | return true; |
273 | 283 | } |
274 | 284 | } |
275 | 285 | |
276 | - if ($softMatch) { |
|
277 | - foreach ($acceptHeader->getAll() as $item) { |
|
286 | + if ($softMatch) |
|
287 | + { |
|
288 | + foreach ($acceptHeader->getAll() as $item) |
|
289 | + { |
|
278 | 290 | $itemValue = \strtolower($item->getValue()); |
279 | - if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) { |
|
291 | + if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) |
|
292 | + { |
|
280 | 293 | return true; |
281 | 294 | } |
282 | 295 | } |
@@ -315,19 +328,22 @@ discard block |
||
315 | 328 | // ensure proper request association |
316 | 329 | $this->request(); |
317 | 330 | |
318 | - if (isset($this->bags[$name])) { |
|
331 | + if (isset($this->bags[$name])) |
|
332 | + { |
|
319 | 333 | return $this->bags[$name]; |
320 | 334 | } |
321 | 335 | |
322 | 336 | $definition = $this->findBagDefinition($name); |
323 | - if (!$definition) { |
|
337 | + if (!$definition) |
|
338 | + { |
|
324 | 339 | throw new InputException(\sprintf("Undefined input bag '%s'", $name)); |
325 | 340 | } |
326 | 341 | |
327 | 342 | $class = $definition['class']; |
328 | 343 | $data = \call_user_func([$this->request(), $definition['source']]); |
329 | 344 | |
330 | - if (!\is_array($data)) { |
|
345 | + if (!\is_array($data)) |
|
346 | + { |
|
331 | 347 | $data = (array)$data; |
332 | 348 | } |
333 | 349 | |
@@ -336,7 +352,8 @@ discard block |
||
336 | 352 | |
337 | 353 | public function hasBag(string $name): bool |
338 | 354 | { |
339 | - if (isset($this->bags[$name])) { |
|
355 | + if (isset($this->bags[$name])) |
|
356 | + { |
|
340 | 357 | return true; |
341 | 358 | } |
342 | 359 | |
@@ -356,12 +373,15 @@ discard block |
||
356 | 373 | */ |
357 | 374 | private function findBagDefinition(string $name): ?array |
358 | 375 | { |
359 | - if (isset($this->bagAssociations[$name])) { |
|
376 | + if (isset($this->bagAssociations[$name])) |
|
377 | + { |
|
360 | 378 | return $this->bagAssociations[$name]; |
361 | 379 | } |
362 | 380 | |
363 | - foreach ($this->bagAssociations as $bag) { |
|
364 | - if (isset($bag['alias']) && $bag['alias'] === $name) { |
|
381 | + foreach ($this->bagAssociations as $bag) |
|
382 | + { |
|
383 | + if (isset($bag['alias']) && $bag['alias'] === $name) |
|
384 | + { |
|
365 | 385 | return $bag; |
366 | 386 | } |
367 | 387 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | #[Proxy] private readonly ContainerInterface $container, |
122 | 122 | /** @invisible */ |
123 | 123 | HttpConfig $config = new HttpConfig() |
124 | - ) { |
|
124 | + ){ |
|
125 | 125 | $this->bagAssociations = \array_merge($this->bagAssociations, $config->getInputBags()); |
126 | 126 | } |
127 | 127 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | { |
151 | 151 | $input = clone $this; |
152 | 152 | |
153 | - if ($add) { |
|
154 | - $input->prefix .= '.' . $prefix; |
|
153 | + if ($add){ |
|
154 | + $input->prefix .= '.'.$prefix; |
|
155 | 155 | $input->prefix = \trim($input->prefix, '.'); |
156 | - } else { |
|
156 | + }else{ |
|
157 | 157 | $input->prefix = $prefix; |
158 | 158 | } |
159 | 159 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | return match (true) { |
171 | 171 | empty($path) => '/', |
172 | - $path[0] !== '/' => '/' . $path, |
|
172 | + $path[0] !== '/' => '/'.$path, |
|
173 | 173 | default => $path |
174 | 174 | }; |
175 | 175 | } |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function request(): Request |
191 | 191 | { |
192 | - try { |
|
192 | + try{ |
|
193 | 193 | $request = $this->container->get(Request::class); |
194 | - } catch (ContainerExceptionInterface $e) { |
|
194 | + }catch (ContainerExceptionInterface $e){ |
|
195 | 195 | throw new ScopeException( |
196 | 196 | 'Unable to get `ServerRequestInterface` in active container scope', |
197 | 197 | $e->getCode(), |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | // Flushing input state |
203 | - if ($this->request !== $request) { |
|
203 | + if ($this->request !== $request){ |
|
204 | 204 | $this->bags = []; |
205 | 205 | $this->request = $request; |
206 | 206 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | $position = \strrpos($header, 'Bearer '); |
219 | 219 | |
220 | - if ($position !== false) { |
|
220 | + if ($position !== false){ |
|
221 | 221 | $header = \substr($header, $position + 7); |
222 | 222 | |
223 | 223 | return \str_contains($header, ',') |
@@ -271,16 +271,16 @@ discard block |
||
271 | 271 | public function isJsonExpected(bool $softMatch = false): bool |
272 | 272 | { |
273 | 273 | $acceptHeader = AcceptHeader::fromString($this->request()->getHeaderLine('Accept')); |
274 | - foreach ($this->jsonTypes as $jsonType) { |
|
275 | - if ($acceptHeader->has($jsonType)) { |
|
274 | + foreach ($this->jsonTypes as $jsonType){ |
|
275 | + if ($acceptHeader->has($jsonType)){ |
|
276 | 276 | return true; |
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | - if ($softMatch) { |
|
281 | - foreach ($acceptHeader->getAll() as $item) { |
|
280 | + if ($softMatch){ |
|
281 | + foreach ($acceptHeader->getAll() as $item){ |
|
282 | 282 | $itemValue = \strtolower($item->getValue()); |
283 | - if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) { |
|
283 | + if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')){ |
|
284 | 284 | return true; |
285 | 285 | } |
286 | 286 | } |
@@ -319,19 +319,19 @@ discard block |
||
319 | 319 | // ensure proper request association |
320 | 320 | $this->request(); |
321 | 321 | |
322 | - if (isset($this->bags[$name])) { |
|
322 | + if (isset($this->bags[$name])){ |
|
323 | 323 | return $this->bags[$name]; |
324 | 324 | } |
325 | 325 | |
326 | 326 | $definition = $this->findBagDefinition($name); |
327 | - if (!$definition) { |
|
327 | + if (!$definition){ |
|
328 | 328 | throw new InputException(\sprintf("Undefined input bag '%s'", $name)); |
329 | 329 | } |
330 | 330 | |
331 | 331 | $class = $definition['class']; |
332 | 332 | $data = \call_user_func([$this->request(), $definition['source']]); |
333 | 333 | |
334 | - if (!\is_array($data)) { |
|
334 | + if (!\is_array($data)){ |
|
335 | 335 | $data = (array)$data; |
336 | 336 | } |
337 | 337 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | |
341 | 341 | public function hasBag(string $name): bool |
342 | 342 | { |
343 | - if (isset($this->bags[$name])) { |
|
343 | + if (isset($this->bags[$name])){ |
|
344 | 344 | return true; |
345 | 345 | } |
346 | 346 | |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | */ |
361 | 361 | private function findBagDefinition(string $name): ?array |
362 | 362 | { |
363 | - if (isset($this->bagAssociations[$name])) { |
|
363 | + if (isset($this->bagAssociations[$name])){ |
|
364 | 364 | return $this->bagAssociations[$name]; |
365 | 365 | } |
366 | 366 | |
367 | - foreach ($this->bagAssociations as $bag) { |
|
368 | - if (isset($bag['alias']) && $bag['alias'] === $name) { |
|
367 | + foreach ($this->bagAssociations as $bag){ |
|
368 | + if (isset($bag['alias']) && $bag['alias'] === $name){ |
|
369 | 369 | return $bag; |
370 | 370 | } |
371 | 371 | } |
@@ -10,14 +10,14 @@ |
||
10 | 10 | */ |
11 | 11 | final class ServerBag extends InputBag |
12 | 12 | { |
13 | - public function has(int|string $name): bool |
|
13 | + public function has(int | string $name): bool |
|
14 | 14 | { |
15 | - return parent::has($this->normalize((string) $name)); |
|
15 | + return parent::has($this->normalize((string)$name)); |
|
16 | 16 | } |
17 | 17 | |
18 | - public function get(int|string $name, mixed $default = null): mixed |
|
18 | + public function get(int | string $name, mixed $default = null): mixed |
|
19 | 19 | { |
20 | - return parent::get($this->normalize((string) $name), $default); |
|
20 | + return parent::get($this->normalize((string)$name), $default); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function fetch(array $keys, bool $fill = false, mixed $filler = null): array |