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.

Factory::createFromBuzz()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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