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

ContredanseDbFactory::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 12
ccs 0
cts 11
cp 0
crap 12
rs 10
c 0
b 0
f 0
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