GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 052873...ac5a7d )
by Cees-Jan
72:07 queued 58:52
created

Factory::createFromReactHttpClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 5
crap 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation\Transport;
4
5
use ApiClients\Foundation\Middleware\Locator\Locator;
6
use Clue\React\Buzz\Browser;
7
use Clue\React\Buzz\Io\Sender;
8
use Psr\Container\ContainerInterface;
9
use React\Dns\Resolver\Factory as ResolverFactory;
10
use React\Dns\Resolver\Resolver;
11
use React\EventLoop\LoopInterface;
12
use React\HttpClient\Client as HttpClient;
13
use React\HttpClient\Factory as HttpClientFactory;
14
15
class Factory
16
{
17
    /**
18
     * @param ContainerInterface $container
19
     * @param LoopInterface $loop
20
     * @param array $options
21
     * @return Client
22
     */
23 1
    public static function create(
24
        ContainerInterface $container,
25
        LoopInterface $loop,
26
        array $options = []
27
    ): Client {
28 1
        if (!isset($options[Options::DNS])) {
29 1
            $options[Options::DNS] = '8.8.8.8';
30
        }
31
32 1
        $resolver = (new ResolverFactory())->createCached($options[Options::DNS], $loop);
33 1
        $httpClient = (new HttpClientFactory())->create($loop, $resolver);
34
35 1
        return self::createFromReactHttpClient(
36 1
            $container,
37 1
            $httpClient,
38 1
            $resolver,
39 1
            $loop,
40 1
            $options
41
        );
42
    }
43
44
    /**
45
     * @param ContainerInterface $container
46
     * @param HttpClient $httpClient
47
     * @param Resolver $resolver
48
     * @param LoopInterface $loop
49
     * @param array $options
50
     * @return Client
51
     */
52 1
    public static function createFromReactHttpClient(
53
        ContainerInterface $container,
54
        HttpClient $httpClient,
0 ignored issues
show
Unused Code introduced by
The parameter $httpClient is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
        Resolver $resolver,
56
        LoopInterface $loop,
57
        array $options = []
58
    ): Client {
59 1
        return self::createFromBuzz(
60 1
            $container,
61 1
            $loop,
62 1
            (new Browser($loop, Sender::createFromLoopDns($loop, $resolver)))->withOptions([
63 1
                'streaming' => true,
64
            ]),
65 1
            $options
66
        );
67
    }
68
69
    /**
70
     * @param ContainerInterface $container
71
     * @param LoopInterface $loop
72
     * @param Browser $buzz
73
     * @param array $options
74
     * @return Client
75
     */
76 1
    public static function createFromBuzz(
77
        ContainerInterface $container,
78
        LoopInterface $loop,
79
        Browser $buzz,
80
        array $options = []
81
    ): Client {
82 1
        return new Client(
83
            $loop,
84 1
            $container->get(Locator::class),
85
            $buzz,
86 1
            $options
87
        );
88
    }
89
}
90