Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
4 / 4 |
ClosureRequestHandler | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
4 / 4 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
handle | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
1 | <?php declare(strict_types=1); |
2 | |
3 | namespace Taproot\IndieAuth\Middleware; |
4 | |
5 | use Psr\Http\Message\ServerRequestInterface; |
6 | use Psr\Http\Message\ResponseInterface; |
7 | use Psr\Http\Server\RequestHandlerInterface; |
8 | |
9 | class ClosureRequestHandler implements RequestHandlerInterface { |
10 | protected $callable; |
11 | |
12 | protected array $args; |
13 | |
14 | public function __construct(callable $callable) { |
15 | $this->callable = $callable; |
16 | $this->args = array_slice(func_get_args(), 1); |
17 | } |
18 | |
19 | public function handle(ServerRequestInterface $request): ResponseInterface { |
20 | return call_user_func_array($this->callable, array_merge([$request], $this->args)); |
21 | } |
22 | } |