Conditions | 3 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
60 | 2 | public function getClient(string $name, string $databaseName = null): Client |
|
61 | { |
||
62 | 2 | $clientKey = !is_null($databaseName) ? $name.'.'.$databaseName : $name; |
|
63 | |||
64 | 2 | if (!isset($this->clients[$clientKey])) { |
|
65 | 2 | $conf = $this->configurations[$name]; |
|
66 | 2 | $uri = sprintf('mongodb://%s:%d', $conf->getHost(), $conf->getPort()); |
|
67 | 2 | $options = array_merge($conf->getCredentialsArray(), ['db' => $databaseName]); |
|
68 | 2 | $this->clients[$clientKey] = new Client($uri, $options); |
|
69 | } |
||
70 | |||
71 | 2 | return $this->clients[$clientKey]; |
|
72 | } |
||
73 | } |
||
74 |