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 ( 85120a...778995 )
by Baptiste
02:26
created

bootstrap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 68
Code Lines 39

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 34
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 39
nc 2
nop 7
dl 0
loc 68
ccs 34
cts 34
cp 1
crap 2
rs 9.296
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP;
5
6
use Innmind\Socket\Internet\Transport as Socket;
7
use Innmind\Url\UrlInterface;
8
use Innmind\TimeContinuum\{
9
    TimeContinuumInterface,
10
    ElapsedPeriod,
11
};
12
use Innmind\CLI\Command as CLICommand;
13
use Innmind\Immutable\{
14
    SetInterface,
15
    Set,
16
    MapInterface,
17
};
18
use Psr\Log\LoggerInterface;
19
20
function bootstrap(
21
    Socket $transport,
22
    UrlInterface $server,
23
    ElapsedPeriod $timeout,
24
    TimeContinuumInterface $clock,
25
    LoggerInterface $logger = null,
26
    SetInterface $protocols = null,
27
    SetInterface $argumentTranslators = null
28
): array {
29 1
    $argumentTranslators = $argumentTranslators ?? Set::of(
30 1
        Transport\Protocol\ArgumentTranslator::class,
31 1
        new Transport\Protocol\ArgumentTranslator\ValueTranslator
32
    );
33 1
    $protocols = $protocols ?? Set::of(
34 1
        Transport\Protocol::class,
35 1
        new Transport\Protocol\v091\Protocol(
36 1
            new Transport\Protocol\ArgumentTranslator\Delegate(...$argumentTranslators)
37
        )
38
    );
39
40 1
    $connection = new Transport\Connection\Lazy(
41 1
        $transport,
42 1
        $server,
43 1
        new Transport\Protocol\Delegate(...$protocols),
44 1
        $timeout,
45 1
        $clock
46
    );
47
48 1
    if ($logger instanceof LoggerInterface) {
49 1
        $connection = new Transport\Connection\Logger($connection, $logger);
50
    }
51
52
    return [
53
        'client' => [
54 1
            'basic' => new Client\Client($connection),
55
            'fluent' => static function(Client $client): Client {
56 1
                return new Client\Fluent($client);
57 1
            },
58
            'logger' => static function(Client $client) use ($logger): Client {
59 1
                return new Client\Logger($client, $logger);
60 1
            },
61
            'signal_aware' => static function(Client $client): Client {
62 1
                return new Client\SignalAware($client);
63 1
            },
64
            'auto_declare' => static function(SetInterface $exchanges, SetInterface $queues, SetInterface $bindings): callable {
65
                return static function(Client $client) use ($exchanges, $queues, $bindings): Client {
66 1
                    return new Client\AutoDeclare($client, $exchanges, $queues, $bindings);
67 1
                };
68 1
            },
69
        ],
70
        'command' => [
71
            'purge' => static function(Client $client): CLICommand {
72 1
                return new Command\Purge($client);
73 1
            },
74
            'get' => static function(MapInterface $consumers): callable {
75
                return static function(Client $client) use ($consumers): CLICommand {
76 1
                    return new Command\Get($client, new Consumers($consumers));
77 1
                };
78 1
            },
79
            'consume' => static function(MapInterface $consumers): callable {
80
                return static function(Client $client) use ($consumers): CLICommand {
81 1
                    return new Command\Consume($client, new Consumers($consumers));
82 1
                };
83 1
            },
84
        ],
85
        'producers' => static function(SetInterface $exchanges): callable {
86
            return static function(Client $client) use ($exchanges): Producers {
87 1
                return Producers::fromDeclarations($client, ...$exchanges);
88 1
            };
89 1
        },
90
    ];
91
}
92