| Conditions | 5 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5.1647 |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 6 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
| 20 | { |
||
| 21 | 6 | $config = $this->getConfig(); |
|
| 22 | 6 | $uri = $request->getUri(); |
|
| 23 | 6 | $response = $handler->handle($request); |
|
| 24 | |||
| 25 | 6 | if (isset($config['path_disable'])) { |
|
| 26 | foreach ($config['path_disable'] as $path) { |
||
| 27 | if (str_starts_with($uri->getPath(), $path)) { |
||
| 28 | return $response; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | 6 | $path = $this->normalize($uri->getPath()); |
|
| 34 | |||
| 35 | 6 | if ($path === $uri->getPath()) { |
|
| 36 | 2 | return $response; |
|
| 37 | } |
||
| 38 | |||
| 39 | 4 | $location = $uri->withPath($path) |
|
| 40 | 4 | ->__toString(); |
|
| 41 | 4 | $factory = Factory::getResponseFactory(); |
|
| 42 | 4 | $response = $factory->createResponse(HttpStatus::STATUS_MOVED_PERMANENTLY); |
|
| 43 | |||
| 44 | 4 | return $response->withHeader(self::HEADER, $location); |
|
| 45 | } |
||
| 65 |