@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | { |
29 | 29 | $scope = self::getAccessor($container)->scope; |
30 | 30 | $result = []; |
31 | - do { |
|
31 | + do |
|
32 | + { |
|
32 | 33 | $result[] = $scope->getScopeName(); |
33 | 34 | $scope = $scope->getParentScope(); |
34 | 35 | } while ($scope !== null); |
@@ -51,7 +52,8 @@ discard block |
||
51 | 52 | |
52 | 53 | $container ??= ContainerScope::getContainer(); |
53 | 54 | |
54 | - if (!$container instanceof Container) { |
|
55 | + if (!$container instanceof Container) |
|
56 | + { |
|
55 | 57 | throw new \RuntimeException('Container is not available.'); |
56 | 58 | } |
57 | 59 |
@@ -151,10 +151,13 @@ discard block |
||
151 | 151 | { |
152 | 152 | $input = clone $this; |
153 | 153 | |
154 | - if ($add) { |
|
154 | + if ($add) |
|
155 | + { |
|
155 | 156 | $input->prefix .= '.' . $prefix; |
156 | 157 | $input->prefix = \trim($input->prefix, '.'); |
157 | - } else { |
|
158 | + } |
|
159 | + else |
|
160 | + { |
|
158 | 161 | $input->prefix = $prefix; |
159 | 162 | } |
160 | 163 | |
@@ -190,9 +193,12 @@ discard block |
||
190 | 193 | */ |
191 | 194 | public function request(): Request |
192 | 195 | { |
193 | - try { |
|
196 | + try |
|
197 | + { |
|
194 | 198 | $request = $this->container->get(Request::class); |
195 | - } catch (ContainerExceptionInterface $e) { |
|
199 | + } |
|
200 | + catch (ContainerExceptionInterface $e) |
|
201 | + { |
|
196 | 202 | $scope = implode('.', \array_reverse(Introspector::scopeNames($this->container))); |
197 | 203 | throw new ScopeException( |
198 | 204 | "Unable to get `ServerRequestInterface` in the `$scope` container scope", |
@@ -202,7 +208,8 @@ discard block |
||
202 | 208 | } |
203 | 209 | |
204 | 210 | // Flushing input state |
205 | - if ($this->request !== $request) { |
|
211 | + if ($this->request !== $request) |
|
212 | + { |
|
206 | 213 | $this->bags = []; |
207 | 214 | $this->request = $request; |
208 | 215 | } |
@@ -219,7 +226,8 @@ discard block |
||
219 | 226 | |
220 | 227 | $position = \strrpos($header, 'Bearer '); |
221 | 228 | |
222 | - if ($position !== false) { |
|
229 | + if ($position !== false) |
|
230 | + { |
|
223 | 231 | $header = \substr($header, $position + 7); |
224 | 232 | |
225 | 233 | return \str_contains($header, ',') |
@@ -273,16 +281,21 @@ discard block |
||
273 | 281 | public function isJsonExpected(bool $softMatch = false): bool |
274 | 282 | { |
275 | 283 | $acceptHeader = AcceptHeader::fromString($this->request()->getHeaderLine('Accept')); |
276 | - foreach ($this->jsonTypes as $jsonType) { |
|
277 | - if ($acceptHeader->has($jsonType)) { |
|
284 | + foreach ($this->jsonTypes as $jsonType) |
|
285 | + { |
|
286 | + if ($acceptHeader->has($jsonType)) |
|
287 | + { |
|
278 | 288 | return true; |
279 | 289 | } |
280 | 290 | } |
281 | 291 | |
282 | - if ($softMatch) { |
|
283 | - foreach ($acceptHeader->getAll() as $item) { |
|
292 | + if ($softMatch) |
|
293 | + { |
|
294 | + foreach ($acceptHeader->getAll() as $item) |
|
295 | + { |
|
284 | 296 | $itemValue = \strtolower((string) $item->getValue()); |
285 | - if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) { |
|
297 | + if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) |
|
298 | + { |
|
286 | 299 | return true; |
287 | 300 | } |
288 | 301 | } |
@@ -321,19 +334,22 @@ discard block |
||
321 | 334 | // ensure proper request association |
322 | 335 | $this->request(); |
323 | 336 | |
324 | - if (isset($this->bags[$name])) { |
|
337 | + if (isset($this->bags[$name])) |
|
338 | + { |
|
325 | 339 | return $this->bags[$name]; |
326 | 340 | } |
327 | 341 | |
328 | 342 | $definition = $this->findBagDefinition($name); |
329 | - if (!$definition) { |
|
343 | + if (!$definition) |
|
344 | + { |
|
330 | 345 | throw new InputException(\sprintf("Undefined input bag '%s'", $name)); |
331 | 346 | } |
332 | 347 | |
333 | 348 | $class = $definition['class']; |
334 | 349 | $data = \call_user_func([$this->request(), $definition['source']]); |
335 | 350 | |
336 | - if (!\is_array($data)) { |
|
351 | + if (!\is_array($data)) |
|
352 | + { |
|
337 | 353 | $data = (array)$data; |
338 | 354 | } |
339 | 355 | |
@@ -342,7 +358,8 @@ discard block |
||
342 | 358 | |
343 | 359 | public function hasBag(string $name): bool |
344 | 360 | { |
345 | - if (isset($this->bags[$name])) { |
|
361 | + if (isset($this->bags[$name])) |
|
362 | + { |
|
346 | 363 | return true; |
347 | 364 | } |
348 | 365 | |
@@ -362,12 +379,15 @@ discard block |
||
362 | 379 | */ |
363 | 380 | private function findBagDefinition(string $name): ?array |
364 | 381 | { |
365 | - if (isset($this->bagAssociations[$name])) { |
|
382 | + if (isset($this->bagAssociations[$name])) |
|
383 | + { |
|
366 | 384 | return $this->bagAssociations[$name]; |
367 | 385 | } |
368 | 386 | |
369 | - foreach ($this->bagAssociations as $bag) { |
|
370 | - if (isset($bag['alias']) && $bag['alias'] === $name) { |
|
387 | + foreach ($this->bagAssociations as $bag) |
|
388 | + { |
|
389 | + if (isset($bag['alias']) && $bag['alias'] === $name) |
|
390 | + { |
|
371 | 391 | return $bag; |
372 | 392 | } |
373 | 393 | } |