AccessLoggerFactory::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
ccs 0
cts 8
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infra\Log;
6
7
use App\Exception\ConfigException;
8
use Psr\Container\ContainerInterface;
9
10
class AccessLoggerFactory
11
{
12
    public function __invoke(ContainerInterface $container): AccessLogger
13
    {
14
        $entityManager = $container->get('doctrine.entity_manager.orm_default') ?? null;
15
16
        if ($entityManager === null) {
17
            throw new ConfigException('EntityManager / doctrine.entity_manager.orm_default is not registered.');
18
        }
19
20
        return new AccessLogger(
21
            $entityManager
22
        );
23
    }
24
}
25