Completed
Push — master ( 868d0c...3a5cb0 )
by Pierre
02:02 queued 20s
created

ClientFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getClient() 0 16 1
1
<?php
2
3
namespace Ola\RabbitMqAdminToolkitBundle;
4
5
use Http\Client\Common\Plugin\ErrorPlugin;
6
use Http\Client\Common\PluginClient;
7
use Http\Discovery\HttpClientDiscovery;
8
use RabbitMq\ManagementApi\Client;
9
10
class ClientFactory
11
{
12
    /**
13
     * @param string $scheme
14
     * @param string $host
15
     * @param string $user
16
     * @param string $pass
17
     * @param int $port
18
     *
19
     * @return Client
20
     */
21
    public function getClient(string $scheme, string $host, string $user, string $pass, int $port = 80): Client
22
    {
23
        return new Client(
24
            new PluginClient(HttpClientDiscovery::find(), [
25
                new ErrorPlugin()
26
            ]),
27
            sprintf(
28
                '%s://%s:%d',
29
                $scheme,
30
                $host,
31
                $port
32
            ),
33
            $user,
34
            $pass
35
        );
36
    }
37
}
38