Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| RequestHandler | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | /** |
| 4 | * Pop PHP Framework (https://www.popphp.org/) |
| 5 | * |
| 6 | * @link https://github.com/popphp/popphp-framework |
| 7 | * @author Nick Sagona, III <nick@popphp.org> |
| 8 | * @copyright Copyright (c) 2009-2026 Nick Sagona, III |
| 9 | * @license https://www.popphp.org/license New BSD License |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * @namespace |
| 14 | */ |
| 15 | namespace Pop\Middleware\Psr15; |
| 16 | |
| 17 | use Psr\Http\Message\ResponseInterface; |
| 18 | use Psr\Http\Message\ServerRequestInterface; |
| 19 | use Psr\Http\Server\RequestHandlerInterface; |
| 20 | |
| 21 | /** |
| 22 | * PSR-15 request handler class |
| 23 | * |
| 24 | * Wraps a plain closure (Pop's own "what happens when the middleware chain is |
| 25 | * exhausted" concept) as a PSR-15 terminal request handler. |
| 26 | * |
| 27 | * @category Pop |
| 28 | * @package Pop\Middleware |
| 29 | * @author Nick Sagona, III <nick@popphp.org> |
| 30 | * @copyright Copyright (c) 2009-2026 Nick Sagona, III |
| 31 | * @license https://www.popphp.org/license New BSD License |
| 32 | * @version 5.0.0 |
| 33 | */ |
| 34 | class RequestHandler implements RequestHandlerInterface |
| 35 | { |
| 36 | |
| 37 | /** |
| 38 | * Dispatch closure |
| 39 | * @var \Closure |
| 40 | */ |
| 41 | protected \Closure $dispatch; |
| 42 | |
| 43 | /** |
| 44 | * Constructor |
| 45 | * |
| 46 | * Instantiate the request handler object. |
| 47 | * |
| 48 | * @param \Closure $dispatch |
| 49 | */ |
| 50 | public function __construct(\Closure $dispatch) |
| 51 | { |
| 52 | $this->dispatch = $dispatch; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Handle the request |
| 57 | * |
| 58 | * @param ServerRequestInterface $request |
| 59 | * @return ResponseInterface |
| 60 | */ |
| 61 | public function handle(ServerRequestInterface $request): ResponseInterface |
| 62 | { |
| 63 | return ($this->dispatch)($request); |
| 64 | } |
| 65 | |
| 66 | } |