Completed
Pull Request — master (#447)
by Alejandro
06:42
created

LoggerAwareDelegatorFactory::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 10
eloc 4
ccs 5
cts 5
cp 1
cc 2
nc 2
nop 3
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\Common\Logger;
5
6
use Psr\Container\ContainerInterface;
7
use Psr\Log;
8
9
class LoggerAwareDelegatorFactory
10
{
11 2
    public function __invoke(ContainerInterface $container, $name, callable $callback)
12
    {
13 2
        $instance = $callback();
14 2
        if ($instance instanceof Log\LoggerAwareInterface) {
15 1
            $instance->setLogger($container->get(Log\LoggerInterface::class));
16
        }
17
18 2
        return $instance;
19
    }
20
}
21