forked from olaurendeau/RabbitMqAdminToolkitBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientFactory.php
37 lines (34 loc) · 854 Bytes
/
ClientFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Ola\RabbitMqAdminToolkitBundle;
use Http\Client\Common\Plugin\ErrorPlugin;
use Http\Client\Common\PluginClient;
use Http\Discovery\HttpClientDiscovery;
use RabbitMq\ManagementApi\Client;
class ClientFactory
{
/**
* @param string $scheme
* @param string $host
* @param string $user
* @param string $pass
* @param int $port
*
* @return Client
*/
public function getClient(string $scheme, string $host, string $user, string $pass, int $port = 80): Client
{
return new Client(
new PluginClient(HttpClientDiscovery::find(), [
new ErrorPlugin()
]),
sprintf(
'%s://%s:%d',
$scheme,
$host,
$port
),
$user,
$pass
);
}
}