ConnectionConfigs   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setConnectionConfigs() 0 4 2
A getConnectionConfig() 0 3 1
A __construct() 0 3 1
A hasConnectionConfig() 0 3 1
A setConnectionConfig() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasDoctrine\Config;
6
7
class ConnectionConfigs
8
{
9
    /**
10
     * @param array<mixed> $configs
11
     */
12
    public function __construct(private array $configs)
13
    {
14
        $this->setConnectionConfigs($configs);
15
    }
16
17
    public function hasConnectionConfig(string $name): bool
18
    {
19
        return isset($this->configs[$name]);
20
    }
21
22
    /**
23
     * @return array<string, mixed>
24
     */
25
    public function getConnectionConfig(string $name): array
26
    {
27
        return $this->configs[$name] ?? [];
28
    }
29
30
    /**
31
     * @param array<string, mixed> $connectionConfigs
32
     */
33
    public function setConnectionConfigs(array $connectionConfigs): void
34
    {
35
        foreach ($connectionConfigs as $name => $connectionConfig) {
36
            $this->setConnectionConfig($name, $connectionConfig);
37
        }
38
    }
39
40
    /**
41
     * @param array<string, mixed> $connectionConfig
42
     */
43
    public function setConnectionConfig(string $name, array $connectionConfig): void
44
    {
45
        $this->configs[$name] = $connectionConfig;
46
    }
47
}
48