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 ( 55f993...f21656 )
by Cees-Jan
09:43
created

Factory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 15
nc 2
nop 3
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation\Transport;
4
5
use Clue\React\Buzz\Browser;
6
use Clue\React\Buzz\Io\Sender;
7
use Interop\Container\ContainerInterface;
8
use React\Dns\Resolver\Factory as ResolverFactory;
9
use React\Dns\Resolver\Resolver;
10
use React\EventLoop\LoopInterface;
11
use React\HttpClient\Client as HttpClient;
12
use React\HttpClient\Factory as HttpClientFactory;
13
14
class Factory
15
{
16
    /**
17
     * @param ContainerInterface $container
18
     * @param LoopInterface $loop
19
     * @param array $options
20
     * @return Client
21
     */
22
    public static function create(
23
        ContainerInterface $container,
24
        LoopInterface $loop,
25
        array $options = []
26
    ): Client {
27
        if (!isset($options[Options::DNS])) {
28
            $options[Options::DNS] = '8.8.8.8';
29
        }
30
31
        $resolver = (new ResolverFactory())->createCached($options[Options::DNS], $loop);
32
        $httpClient = (new HttpClientFactory())->create($loop, $resolver);
33
34
        return self::createFromReactHttpClient(
35
            $container,
36
            $httpClient,
37
            $resolver,
38
            $loop,
39
            $options
40
        );
41
    }
42
43
    /**
44
     * @param ContainerInterface $container
45
     * @param HttpClient $httpClient
46
     * @param Resolver $resolver
47
     * @param LoopInterface $loop
48
     * @param array $options
49
     * @return Client
50
     */
51
    public static function createFromReactHttpClient(
52
        ContainerInterface $container,
53
        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...
54
        Resolver $resolver,
55
        LoopInterface $loop,
56
        array $options = []
57
    ): Client {
58
        return self::createFromBuzz(
59
            $container,
60
            $loop,
61
            (new Browser($loop, Sender::createFromLoopDns($loop, $resolver)))->withOptions([
62
                'streaming' => true,
63
            ]),
64
            $options
65
        );
66
    }
67
68
    /**
69
     * @param ContainerInterface $container
70
     * @param LoopInterface $loop
71
     * @param Browser $buzz
72
     * @param array $options
73
     * @return Client
74
     */
75
    public static function createFromBuzz(
76
        ContainerInterface $container,
77
        LoopInterface $loop,
78
        Browser $buzz,
79
        array $options = []
80
    ): Client {
81
        return new Client(
82
            $loop,
83
            $container,
84
            $buzz,
85
            $options
86
        );
87
    }
88
}
89