ConnectionFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 12

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 12
dl 0
loc 37
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B make() 0 34 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQPBundle\Factory;
5
6
use Innmind\AMQP\Transport\{
7
    Connection\Lazy,
8
    Protocol
9
};
10
use Innmind\Socket\Internet\Transport;
11
use Innmind\TimeContinuum\{
12
    TimeContinuumInterface,
13
    ElapsedPeriod
14
};
15
use Innmind\Url\{
16
    Url,
17
    NullScheme,
18
    Authority,
19
    Authority\UserInformation,
20
    Authority\UserInformation\User,
21
    Authority\UserInformation\Password,
22
    Authority\Host,
23
    Authority\Port,
24
    Path,
25
    NullQuery,
26
    NullFragment
27
};
28
29
final class ConnectionFactory
30
{
31 16
    public static function make(
32
        string $transport,
33
        array $server,
34
        Protocol $protocol,
35
        int $timeout,
36
        TimeContinuumInterface $clock
37
    ): Lazy {
38 16
        $transport = Transport::$transport();
39
40 16
        foreach ($server['transport']['options'] as $key => $value) {
41 2
            $transport = $transport->withOption($key, $value);
42
        }
43
44 16
        return new Lazy(
45 16
            $transport,
46 16
            new Url(
47 16
                new NullScheme,
48 16
                new Authority(
49 16
                    new UserInformation(
50 16
                        new User($server['user']),
51 16
                        new Password($server['password'])
52
                    ),
53 16
                    new Host($server['host']),
54 16
                    new Port($server['port'])
55
                ),
56 16
                new Path($server['vhost']),
57 16
                new NullQuery,
58 16
                new NullFragment
59
            ),
60 16
            $protocol,
61 16
            new ElapsedPeriod($timeout),
62 16
            $clock
63
        );
64
    }
65
}
66