@@ -11,5 +11,5 @@ |
||
11 | 11 | * |
12 | 12 | * @param string|null $type The resource type or null if unknown |
13 | 13 | */ |
14 | - public function resolve(mixed $resource, string $type = null): LoaderInterface|false; |
|
14 | + public function resolve(mixed $resource, string $type = null): LoaderInterface | false; |
|
15 | 15 | } |
@@ -16,15 +16,15 @@ |
||
16 | 16 | */ |
17 | 17 | public function __construct(array $loaders = []) |
18 | 18 | { |
19 | - foreach ($loaders as $loader) { |
|
19 | + foreach ($loaders as $loader){ |
|
20 | 20 | $this->addLoader($loader); |
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | - public function resolve(mixed $resource, string $type = null): LoaderInterface|false |
|
24 | + public function resolve(mixed $resource, string $type = null): LoaderInterface | false |
|
25 | 25 | { |
26 | - foreach ($this->loaders as $loader) { |
|
27 | - if ($loader->supports($resource, $type)) { |
|
26 | + foreach ($this->loaders as $loader){ |
|
27 | + if ($loader->supports($resource, $type)){ |
|
28 | 28 | return $loader; |
29 | 29 | } |
30 | 30 | } |
@@ -16,15 +16,18 @@ |
||
16 | 16 | */ |
17 | 17 | public function __construct(array $loaders = []) |
18 | 18 | { |
19 | - foreach ($loaders as $loader) { |
|
19 | + foreach ($loaders as $loader) |
|
20 | + { |
|
20 | 21 | $this->addLoader($loader); |
21 | 22 | } |
22 | 23 | } |
23 | 24 | |
24 | 25 | public function resolve(mixed $resource, string $type = null): LoaderInterface|false |
25 | 26 | { |
26 | - foreach ($this->loaders as $loader) { |
|
27 | - if ($loader->supports($resource, $type)) { |
|
27 | + foreach ($this->loaders as $loader) |
|
28 | + { |
|
29 | + if ($loader->supports($resource, $type)) |
|
30 | + { |
|
28 | 31 | return $loader; |
29 | 32 | } |
30 | 33 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function __construct( |
17 | 17 | private readonly FactoryInterface $factory, |
18 | 18 | private readonly ResolverInterface $resolver, |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function load(mixed $resource, string $type = null): RouteCollection |
26 | 26 | { |
27 | - if (!\file_exists($resource)) { |
|
27 | + if (!\file_exists($resource)){ |
|
28 | 28 | throw new LoaderLoadException(\sprintf('File [%s] does not exist.', $resource)); |
29 | 29 | } |
30 | 30 | |
31 | - $load = static function (string $path) { |
|
31 | + $load = static function (string $path){ |
|
32 | 32 | return include $path; |
33 | 33 | }; |
34 | 34 |
@@ -24,11 +24,13 @@ |
||
24 | 24 | */ |
25 | 25 | public function load(mixed $resource, string $type = null): RouteCollection |
26 | 26 | { |
27 | - if (!\file_exists($resource)) { |
|
27 | + if (!\file_exists($resource)) |
|
28 | + { |
|
28 | 29 | throw new LoaderLoadException(\sprintf('File [%s] does not exist.', $resource)); |
29 | 30 | } |
30 | 31 | |
31 | - $load = static function (string $path) { |
|
32 | + $load = static function (string $path) |
|
33 | + { |
|
32 | 34 | return include $path; |
33 | 35 | }; |
34 | 36 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | public function __construct( |
18 | 18 | private readonly ContainerInterface $container, |
19 | 19 | private readonly FactoryInterface $factory |
20 | - ) { |
|
20 | + ){ |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -26,27 +26,27 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function createWithMiddleware(array $middleware): Pipeline |
28 | 28 | { |
29 | - if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline) { |
|
29 | + if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline){ |
|
30 | 30 | return $middleware[0]; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $pipeline = $this->factory->make(Pipeline::class); |
34 | 34 | \assert($pipeline instanceof Pipeline); |
35 | 35 | |
36 | - foreach ($middleware as $item) { |
|
37 | - if ($item instanceof MiddlewareInterface) { |
|
36 | + foreach ($middleware as $item){ |
|
37 | + if ($item instanceof MiddlewareInterface){ |
|
38 | 38 | $pipeline->pushMiddleware($item); |
39 | - } elseif (\is_string($item)) { |
|
39 | + } elseif (\is_string($item)){ |
|
40 | 40 | $item = $this->container->get($item); |
41 | 41 | \assert($item instanceof MiddlewareInterface); |
42 | 42 | |
43 | 43 | $pipeline->pushMiddleware($item); |
44 | - } elseif ($item instanceof Autowire) { |
|
44 | + } elseif ($item instanceof Autowire){ |
|
45 | 45 | $item = $item->resolve($this->factory); |
46 | 46 | \assert($item instanceof MiddlewareInterface); |
47 | 47 | |
48 | 48 | $pipeline->pushMiddleware($item); |
49 | - } else { |
|
49 | + }else{ |
|
50 | 50 | $name = get_debug_type($item); |
51 | 51 | throw new RouteException(\sprintf('Invalid middleware `%s`', $name)); |
52 | 52 | } |
@@ -26,27 +26,36 @@ |
||
26 | 26 | */ |
27 | 27 | public function createWithMiddleware(array $middleware): Pipeline |
28 | 28 | { |
29 | - if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline) { |
|
29 | + if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline) |
|
30 | + { |
|
30 | 31 | return $middleware[0]; |
31 | 32 | } |
32 | 33 | |
33 | 34 | $pipeline = $this->factory->make(Pipeline::class); |
34 | 35 | \assert($pipeline instanceof Pipeline); |
35 | 36 | |
36 | - foreach ($middleware as $item) { |
|
37 | - if ($item instanceof MiddlewareInterface) { |
|
37 | + foreach ($middleware as $item) |
|
38 | + { |
|
39 | + if ($item instanceof MiddlewareInterface) |
|
40 | + { |
|
38 | 41 | $pipeline->pushMiddleware($item); |
39 | - } elseif (\is_string($item)) { |
|
42 | + } |
|
43 | + elseif (\is_string($item)) |
|
44 | + { |
|
40 | 45 | $item = $this->container->get($item); |
41 | 46 | \assert($item instanceof MiddlewareInterface); |
42 | 47 | |
43 | 48 | $pipeline->pushMiddleware($item); |
44 | - } elseif ($item instanceof Autowire) { |
|
49 | + } |
|
50 | + elseif ($item instanceof Autowire) |
|
51 | + { |
|
45 | 52 | $item = $item->resolve($this->factory); |
46 | 53 | \assert($item instanceof MiddlewareInterface); |
47 | 54 | |
48 | 55 | $pipeline->pushMiddleware($item); |
49 | - } else { |
|
56 | + } |
|
57 | + else |
|
58 | + { |
|
50 | 59 | $name = get_debug_type($item); |
51 | 60 | throw new RouteException(\sprintf('Invalid middleware `%s`', $name)); |
52 | 61 | } |
@@ -12,8 +12,8 @@ |
||
12 | 12 | private readonly UriInterface $uri, |
13 | 13 | int $code = 0, |
14 | 14 | \Throwable $previous = null |
15 | - ) { |
|
16 | - parent::__construct(\sprintf('Unable to route `%s`.', (string) $uri), $code, $previous); |
|
15 | + ){ |
|
16 | + parent::__construct(\sprintf('Unable to route `%s`.', (string)$uri), $code, $previous); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function getUri(): UriInterface |
@@ -19,9 +19,9 @@ |
||
19 | 19 | */ |
20 | 20 | public function withVerbs(string ...$verbs): RouteInterface |
21 | 21 | { |
22 | - foreach ($verbs as &$verb) { |
|
22 | + foreach ($verbs as &$verb){ |
|
23 | 23 | $verb = \strtoupper($verb); |
24 | - if (!\in_array($verb, RouteInterface::VERBS, true)) { |
|
24 | + if (!\in_array($verb, RouteInterface::VERBS, true)){ |
|
25 | 25 | throw new RouteException(\sprintf('Invalid HTTP verb `%s`', $verb)); |
26 | 26 | } |
27 | 27 |
@@ -19,9 +19,11 @@ |
||
19 | 19 | */ |
20 | 20 | public function withVerbs(string ...$verbs): RouteInterface |
21 | 21 | { |
22 | - foreach ($verbs as &$verb) { |
|
22 | + foreach ($verbs as &$verb) |
|
23 | + { |
|
23 | 24 | $verb = \strtoupper($verb); |
24 | - if (!\in_array($verb, RouteInterface::VERBS, true)) { |
|
25 | + if (!\in_array($verb, RouteInterface::VERBS, true)) |
|
26 | + { |
|
25 | 27 | throw new RouteException(\sprintf('Invalid HTTP verb `%s`', $verb)); |
26 | 28 | } |
27 | 29 |
@@ -10,6 +10,6 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | public readonly ServerRequestInterface $request |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | } |
@@ -12,6 +12,6 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | public readonly ServerRequestInterface $request, |
14 | 14 | public readonly RouteInterface $route, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private readonly string $value |
11 | - ) { |
|
11 | + ){ |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | public function __toString(): string |