LazyRequestHandlerAdapter::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\SlimPsr15;
6
7
use Psr\Container\ContainerInterface;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
12 View Code Duplication
final class LazyRequestHandlerAdapter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var ContainerInterface
16
     */
17
    private $container;
18
19
    /**
20
     * @var string
21
     */
22
    private $serviceId;
23
24 1
    public function __construct(ContainerInterface $container, string $serviceId)
25
    {
26 1
        $this->container = $container;
27 1
        $this->serviceId = $serviceId;
28 1
    }
29
30 1
    public function __invoke(ServerRequestInterface $request): ResponseInterface
31
    {
32
        /** @var RequestHandlerInterface $requestHandler */
33 1
        $requestHandler = $this->container->get($this->serviceId);
34
35 1
        return $requestHandler->handle($request);
36
    }
37
}
38