Passed
Pull Request — master (#224)
by
unknown
13:06
created

Callback::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 2
b 0
f 0
ccs 0
cts 0
cp 0
crap 2
1
<?php
2
3
namespace Yiisoft\Yii\Web\Middleware;
4
5
use Psr\Container\ContainerInterface;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\Server\MiddlewareInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
use Yiisoft\Injector\Injector;
11
12
final class Callback implements MiddlewareInterface
13
{
14
    /**
15
     * @var callable a PHP callback matching signature of [[MiddlewareInterface::process()]].
16
     */
17
    private $callback;
18
    private ContainerInterface $container;
19
20
    public function __construct(callable $callback, ContainerInterface $container)
21
    {
22
        $this->callback = $callback;
23
        $this->container = $container;
24
    }
25
26
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
27
    {
28
        return (new Injector($this->container))->invoke($this->callback, [$request, $handler]);
29
    }
30
}
31