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
Pull Request — master (#7)
by Cees-Jan
06:37
created

Factory::determineUserAgent()   B

Complexity

Conditions 6
Paths 5

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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