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 | /** @var array $args */ |
13 | protected $args; |
14 | |
15 | public function __construct(callable $callable) { |
16 | $this->callable = $callable; |
17 | $this->args = array_slice(func_get_args(), 1); |
18 | } |
19 | |
20 | public function handle(ServerRequestInterface $request): ResponseInterface { |
21 | return call_user_func_array($this->callable, array_merge([$request], $this->args)); |
22 | } |
23 | } |