Passed
Push — master ( dfee8d...a9ed36 )
by Felipe
06:42
created

RequestHandlerClientFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 15
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
1
<?php
2
3
/**
4
 * This file is part of coisa/http.
5
 *
6
 * (c) Felipe Sayão Lobato Abreu <[email protected]>
7
 *
8
 * This source file is subject to the license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
declare(strict_types=1);
13
14
namespace CoiSA\Http\Client;
15
16
use Psr\Container\ContainerInterface;
17
use Psr\Http\Message\ServerRequestFactoryInterface;
18
use Psr\Http\Server\RequestHandlerInterface;
19
20
/**
21
 * Class RequestHandlerClientFactory.php
22
 *
23
 * @package CoiSA\Http\Client
24
 */
25
final class RequestHandlerClientFactory
26
{
27
    /**
28
     * @param ContainerInterface $container
29
     *
30
     * @return RequestHandlerClient
31
     */
32 4
    public function __invoke(ContainerInterface $container): RequestHandlerClient
33
    {
34 4
        $requestHandler = $container->get(RequestHandlerInterface::class);
35
36 4
        $serverRequestFactory = $container->has(ServerRequestFactoryInterface::class) ?
37 4
            $container->get(ServerRequestFactoryInterface::class) : null;
38
39 4
        return new RequestHandlerClient($requestHandler, $serverRequestFactory);
40
    }
41
}
42