Test Failed
Push — master ( 79a4f3...e5bdba )
by Koldo
02:33
created

RouteNotFoundMiddleware::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\React\PSR15\Middleware;
6
7
use Antidot\React\PSR15\Response\PromiseResponse;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Psr\Http\Server\MiddlewareInterface;
11
use Psr\Http\Server\RequestHandlerInterface;
12
use React\Promise\FulfilledPromise;
13
use Zend\Diactoros\Response\HtmlResponse;
14
15
final class RouteNotFoundMiddleware implements MiddlewareInterface
16
{
17
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
18
    {
19
        $promise = new FulfilledPromise();
20
21
        return new PromiseResponse($promise->then(function () {
22
            return new HtmlResponse('<html><head></head><body>Page not found</body></html>', 404);
23
        }));
24
    }
25
}
26