1 | <?php declare(strict_types=1); |
||
15 | final class ClientRegistry |
||
16 | { |
||
17 | /** @var Client[] */ |
||
18 | private $clients; |
||
19 | /** @var ClientConfiguration[] */ |
||
20 | private $configurations; |
||
21 | /** @var string */ |
||
22 | private $environment; |
||
23 | /** @var EventDispatcherInterface */ |
||
24 | private $eventDispatcher; |
||
25 | |||
26 | /** |
||
27 | * ClientRegistry constructor. |
||
28 | * |
||
29 | * @param EventDispatcherInterface $eventDispatcher |
||
30 | * @param string $environment |
||
31 | * |
||
32 | * @internal param DataCollectorLoggerInterface $logger |
||
33 | */ |
||
34 | 30 | public function __construct(EventDispatcherInterface $eventDispatcher, string $environment) |
|
41 | |||
42 | /** |
||
43 | * @param array $configurations |
||
44 | */ |
||
45 | 30 | public function addClientsConfigurations(array $configurations) |
|
51 | |||
52 | /** |
||
53 | * @param string $name |
||
54 | * @param array $conf |
||
55 | */ |
||
56 | 30 | private function addClientConfiguration(string $name, array $conf) |
|
60 | |||
61 | /** |
||
62 | * @param array $conf |
||
63 | * |
||
64 | * @return ClientConfiguration |
||
65 | */ |
||
66 | 30 | private function buildClientConfiguration(array $conf): ClientConfiguration |
|
82 | |||
83 | /** |
||
84 | * @param array $hosts |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | 30 | private function buildConnectionUri(array $hosts): string |
|
104 | |||
105 | /** |
||
106 | * @param string $name |
||
107 | * @param string $databaseName |
||
108 | * |
||
109 | * @return Client |
||
110 | */ |
||
111 | 11 | public function getClientForDatabase(string $name, string $databaseName): Client |
|
115 | |||
116 | /** |
||
117 | * @return array |
||
118 | */ |
||
119 | 1 | public function getClientNames(): array |
|
123 | |||
124 | /** |
||
125 | * @param string $name |
||
126 | * @param string $databaseName |
||
127 | * |
||
128 | * @return Client |
||
129 | */ |
||
130 | 28 | public function getClient(string $name, string $databaseName = null): Client |
|
154 | |||
155 | /** |
||
156 | * @param string $clientName |
||
157 | * @param string $uri |
||
158 | * @param array $options |
||
159 | * @param array $driverOptions |
||
160 | * |
||
161 | * @return Client |
||
162 | */ |
||
163 | 28 | private function buildClient(string $clientName, string $uri, array $options, array $driverOptions): Client |
|
171 | } |
||
172 |