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

LoggerAwareDelegatorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
dl 0
loc 10
rs 10
eloc 5
ccs 5
cts 5
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 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