Total Complexity | 4 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class ConfigurationResolver implements ConfigurationResolverInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var Configuration[] |
||
11 | */ |
||
12 | private $configurations; |
||
13 | |||
14 | /** |
||
15 | * @var Configuration |
||
16 | */ |
||
17 | private $default; |
||
18 | |||
19 | /** |
||
20 | * ConfigurationResolver constructor. |
||
21 | * |
||
22 | * @param Configuration[]|null $configurations |
||
23 | * @param Configuration|null $default |
||
24 | */ |
||
25 | public function __construct(array $configurations = null, Configuration $default = null) |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Get the configuration of the connection |
||
33 | * |
||
34 | * @param string $connectionName |
||
35 | * |
||
36 | * @return Configuration |
||
37 | */ |
||
38 | public function getConfiguration(string $connectionName): ?Configuration |
||
39 | { |
||
40 | if (isset($this->configurations[$connectionName])) { |
||
41 | return $this->configurations[$connectionName]; |
||
42 | } |
||
43 | |||
44 | return $this->default; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Declare a configuration of a connection |
||
49 | * |
||
50 | * @param string $connectionName |
||
51 | * @param Configuration $configuration |
||
52 | */ |
||
53 | public function addConfiguration(string $connectionName, Configuration $configuration): void |
||
56 | } |
||
57 | } |