Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class ConnectionProvider |
||
13 | { |
||
14 | public const DEFAULT = 'default'; |
||
15 | |||
16 | /** @var ConnectionInterface[] $connections */ |
||
17 | private static array $connections = []; |
||
18 | |||
19 | /** |
||
20 | * Returns all connections. |
||
21 | * |
||
22 | * @return ConnectionInterface[] |
||
23 | */ |
||
24 | public static function all(): array |
||
25 | { |
||
26 | return self::$connections; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Returns a connection by name. |
||
31 | */ |
||
32 | public static function get(string $name = self::DEFAULT): ConnectionInterface |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Checks if a connection name exists. |
||
39 | */ |
||
40 | public static function has(string $name = self::DEFAULT): bool |
||
41 | { |
||
42 | return isset(self::$connections[$name]); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Sets a connection by name. |
||
47 | */ |
||
48 | public static function set(ConnectionInterface $connection, string $name = self::DEFAULT): void |
||
51 | } |
||
52 | } |
||
53 |