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 |
|
73 | |||
74 | 30 | /** |
|
75 | 30 | * @param string $name |
|
76 | 30 | * @param string $databaseName |
|
77 | 30 | * |
|
78 | * @return Client |
||
79 | */ |
||
80 | public function getClientForDatabase(string $name, string $databaseName): Client |
||
84 | |||
85 | /** |
||
86 | * @return array |
||
87 | 30 | */ |
|
88 | public function getClientNames(): array |
||
92 | 30 | ||
93 | 30 | /** |
|
94 | 30 | * @param string $name |
|
95 | 30 | * @param string $databaseName |
|
96 | * |
||
97 | * @return Client |
||
98 | */ |
||
99 | public function getClient(string $name, string $databaseName = null): Client |
||
121 | |||
122 | /** |
||
123 | * @param string $clientName |
||
124 | * @param string $uri |
||
125 | 28 | * @param array $options |
|
126 | * @param array $driverOptions |
||
127 | 28 | * |
|
128 | * @return Client |
||
129 | 28 | */ |
|
130 | 28 | private function buildClient(string $clientName, string $uri, array $options, array $driverOptions): Client |
|
138 | } |
||
139 |