Passed
Push — master ( f501a2...a64193 )
by Dominik
03:35
created

LazyRequestHandlerAdapter::__invoke()   A

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
    /**
25
     * @param ContainerInterface $container
26
     * @param string             $serviceId
27
     */
28 1
    public function __construct(ContainerInterface $container, string $serviceId)
29
    {
30 1
        $this->container = $container;
31 1
        $this->serviceId = $serviceId;
32 1
    }
33
34
    /**
35
     * @param ServerRequestInterface $request
36
     *
37
     * @return ResponseInterface
38
     */
39 1
    public function __invoke(ServerRequestInterface $request): ResponseInterface
40
    {
41
        /** @var RequestHandlerInterface $requestHandler */
42 1
        $requestHandler = $this->container->get($this->serviceId);
43
44 1
        return $requestHandler->handle($request);
45
    }
46
}
47