Total Complexity | 5 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class ArrayConnectionProvider implements ConnectionProvider |
||
10 | { |
||
11 | /** @var array<string, Connection> */ |
||
12 | private $connections; |
||
13 | |||
14 | /** @var string */ |
||
15 | private $defaultConnectionName; |
||
16 | |||
17 | /** |
||
18 | * @param array<string, Connection> $connections |
||
19 | */ |
||
20 | public function __construct(array $connections, string $defaultConnectionName) |
||
21 | { |
||
22 | $this->connections = $connections; |
||
23 | $this->defaultConnectionName = $defaultConnectionName; |
||
24 | } |
||
25 | |||
26 | public static function createFromSingleConnection(Connection $connection, string $name = 'default') : self |
||
27 | { |
||
28 | return new self([$name => $connection], $name); |
||
29 | } |
||
30 | |||
31 | public function getDefaultConnection() : Connection |
||
32 | { |
||
33 | return $this->getConnection($this->defaultConnectionName); |
||
34 | } |
||
35 | |||
36 | public function getConnection(string $name) : Connection |
||
43 | } |
||
44 | } |
||
45 |