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

ClientFactory::getClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 5
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