Failed Conditions
Push — master ( 47a38a...a87e0d )
by Sébastien
02:33
created

ContredanseDbFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infra\Db;
6
7
use App\Exception\ConfigException;
8
use Psr\Container\ContainerInterface;
9
10
class ContredanseDbFactory
11
{
12
    public function __invoke(ContainerInterface $container): ContredanseDb
13
    {
14
        $config = $container->get('config')['contredanse'] ?? null;
15
        if ($config === null) {
16
            throw new ConfigException("['contredanse'] config key is missing.");
17
        }
18
        if (!is_array($config['db'] ?? false)) {
19
            throw new ConfigException("['contredanse']['db'] config key is missing.");
20
        }
21
22
        return new ContredanseDb(
23
            $config['db']
24
        );
25
    }
26
}
27