@@ -21,7 +21,7 @@ |
||
21 | 21 | ?string $clientFilename = null, |
22 | 22 | ?string $clientMediaType = null |
23 | 23 | ): UploadedFileInterface { |
24 | - if ($size === null) { |
|
24 | + if ($size === null){ |
|
25 | 25 | $size = $stream->getSize(); |
26 | 26 | } |
27 | 27 |
@@ -14,6 +14,6 @@ |
||
14 | 14 | |
15 | 15 | public function callAction(string $controller, ?string $action = null, array $parameters = []): string |
16 | 16 | { |
17 | - return '@wrapped.' . $this->core->callAction($controller, $action, $parameters); |
|
17 | + return '@wrapped.'.$this->core->callAction($controller, $action, $parameters); |
|
18 | 18 | } |
19 | 19 | } |
@@ -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 |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | private readonly ContainerInterface $container, |
53 | 53 | private readonly ?EventDispatcherInterface $eventDispatcher = null, |
54 | 54 | ?TracerInterface $tracer = null, |
55 | - ) { |
|
55 | + ){ |
|
56 | 56 | $this->tracer = $tracer ?? new NullTracer(); |
57 | - $this->basePath = '/' . \ltrim($basePath, '/'); |
|
57 | + $this->basePath = '/'.\ltrim($basePath, '/'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | return $this->tracer->trace( |
69 | 69 | name: 'Routing', |
70 | 70 | callback: function (SpanInterface $span) use ($request) { |
71 | - try { |
|
71 | + try{ |
|
72 | 72 | $route = $this->matchRoute($request, $routeName); |
73 | - } catch (RouteException $e) { |
|
73 | + }catch (RouteException $e){ |
|
74 | 74 | throw new RouterException('Invalid route definition', $e->getCode(), $e); |
75 | 75 | } |
76 | 76 | |
77 | - if ($route === null) { |
|
77 | + if ($route === null){ |
|
78 | 78 | $this->eventDispatcher?->dispatch(new RouteNotFound($request)); |
79 | 79 | throw new RouteNotFoundException($request->getUri()); |
80 | 80 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | public function getRoute(string $name): RouteInterface |
111 | 111 | { |
112 | - if (isset($this->routes[$name])) { |
|
112 | + if (isset($this->routes[$name])){ |
|
113 | 113 | return $this->routes[$name]; |
114 | 114 | } |
115 | 115 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | public function getRoutes(): array |
120 | 120 | { |
121 | - if (!empty($this->default)) { |
|
121 | + if (!empty($this->default)){ |
|
122 | 122 | return $this->routes + [null => $this->default]; |
123 | 123 | } |
124 | 124 | |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | |
128 | 128 | public function uri(string $route, iterable $parameters = []): UriInterface |
129 | 129 | { |
130 | - try { |
|
130 | + try{ |
|
131 | 131 | return $this->getRoute($route)->uri($parameters); |
132 | - } catch (UndefinedRouteException) { |
|
132 | + }catch (UndefinedRouteException){ |
|
133 | 133 | //In some cases route name can be provided as controller:action pair, we can try to |
134 | 134 | //generate such route automatically based on our default/fallback route |
135 | 135 | return $this->castRoute($route)->uri($parameters); |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | /** @var GroupRegistry $groups */ |
142 | 142 | $groups = $this->container->get(GroupRegistry::class); |
143 | 143 | |
144 | - foreach ($routes->getCollection() as $name => $configurator) { |
|
144 | + foreach ($routes->getCollection() as $name => $configurator){ |
|
145 | 145 | $target = $configurator->target; |
146 | - if ($configurator->core !== null && $target instanceof AbstractTarget) { |
|
146 | + if ($configurator->core !== null && $target instanceof AbstractTarget){ |
|
147 | 147 | $target = $target->withCore($configurator->core); |
148 | 148 | } |
149 | 149 | |
@@ -152,21 +152,21 @@ discard block |
||
152 | 152 | : \ltrim($configurator->pattern, '/'); |
153 | 153 | $route = new Route($pattern, $target, $configurator->defaults); |
154 | 154 | |
155 | - if ($configurator->middleware !== null) { |
|
155 | + if ($configurator->middleware !== null){ |
|
156 | 156 | $route = $route->withMiddleware(...$configurator->middleware); |
157 | 157 | } |
158 | 158 | |
159 | - if ($configurator->methods !== null) { |
|
159 | + if ($configurator->methods !== null){ |
|
160 | 160 | $route = $route->withVerbs(...$configurator->methods); |
161 | 161 | } |
162 | 162 | |
163 | - if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) { |
|
163 | + if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME){ |
|
164 | 164 | $group = $groups->getGroup($configurator->group ?? $groups->getDefaultGroup()); |
165 | 165 | $group->setPrefix($configurator->prefix); |
166 | 166 | $group->addRoute($name, $route); |
167 | 167 | } |
168 | 168 | |
169 | - if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) { |
|
169 | + if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME){ |
|
170 | 170 | $this->setDefault($route); |
171 | 171 | } |
172 | 172 | } |
@@ -177,17 +177,17 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function matchRoute(ServerRequestInterface $request, ?string &$routeName = null): ?RouteInterface |
179 | 179 | { |
180 | - foreach ($this->routes as $name => $route) { |
|
180 | + foreach ($this->routes as $name => $route){ |
|
181 | 181 | // Matched route will return new route instance with matched parameters |
182 | 182 | $matched = $route->match($request); |
183 | 183 | |
184 | - if ($matched !== null) { |
|
184 | + if ($matched !== null){ |
|
185 | 185 | $routeName = $name; |
186 | 186 | return $matched; |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - if ($this->default !== null) { |
|
190 | + if ($this->default !== null){ |
|
191 | 191 | return $this->default->match($request); |
192 | 192 | } |
193 | 193 | |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function configure(RouteInterface $route): RouteInterface |
202 | 202 | { |
203 | - if ($route instanceof ContainerizedInterface && !$route->hasContainer()) { |
|
203 | + if ($route instanceof ContainerizedInterface && !$route->hasContainer()){ |
|
204 | 204 | // isolating route in a given container |
205 | 205 | $route = $route->withContainer($this->container); |
206 | 206 | } |
207 | 207 | |
208 | - try { |
|
208 | + try{ |
|
209 | 209 | $uriHandler = $route->getUriHandler(); |
210 | - } catch (\Throwable) { |
|
210 | + }catch (\Throwable){ |
|
211 | 211 | $uriHandler = $this->uriHandler; |
212 | 212 | } |
213 | 213 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $route, |
231 | 231 | $matches |
232 | 232 | ) |
233 | - ) { |
|
233 | + ){ |
|
234 | 234 | throw new UndefinedRouteException( |
235 | 235 | "Unable to locate route or use default route with 'name/controller:action' pattern" |
236 | 236 | ); |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | /** |
240 | 240 | * @var Matches $matches |
241 | 241 | */ |
242 | - if (!empty($matches['name'])) { |
|
242 | + if (!empty($matches['name'])){ |
|
243 | 243 | $routeObject = $this->getRoute($matches['name']); |
244 | - } elseif ($this->default !== null) { |
|
244 | + } elseif ($this->default !== null){ |
|
245 | 245 | $routeObject = $this->default; |
246 | - } else { |
|
246 | + }else{ |
|
247 | 247 | throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route)); |
248 | 248 | } |
249 | 249 |
@@ -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 | } |
@@ -10,12 +10,12 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | private readonly LoaderRegistryInterface $registry |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function load(mixed $resource, ?string $type = null): mixed |
17 | 17 | { |
18 | - if (false === $loader = $this->registry->resolve($resource, $type)) { |
|
18 | + if (false === $loader = $this->registry->resolve($resource, $type)){ |
|
19 | 19 | throw new LoaderLoadException(\sprintf('Loader for type [%s] not found.', $type ?? '')); |
20 | 20 | } |
21 | 21 |
@@ -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,7 +24,7 @@ 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 |
@@ -14,19 +14,19 @@ |
||
14 | 14 | public function __construct( |
15 | 15 | private readonly RouteCollection $collection, |
16 | 16 | private readonly LoaderInterface $loader |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | - public function import(string|array $resource, ?string $type = null): ImportConfigurator |
|
20 | + public function import(string | array $resource, ?string $type = null): ImportConfigurator |
|
21 | 21 | { |
22 | 22 | $imported = $this->loader->load($resource, $type) ?: []; |
23 | 23 | |
24 | - if (!\is_array($imported)) { |
|
24 | + if (!\is_array($imported)){ |
|
25 | 25 | return new ImportConfigurator($this->collection, $imported); |
26 | 26 | } |
27 | 27 | |
28 | 28 | $mergedCollection = new RouteCollection(); |
29 | - foreach ($imported as $subCollection) { |
|
29 | + foreach ($imported as $subCollection){ |
|
30 | 30 | $mergedCollection->addCollection($subCollection); |
31 | 31 | } |
32 | 32 |
@@ -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 | } |