Completed
Push — develop ( f102ca...488b09 )
by Mathias
20:12 queued 11:00
created

LogStrategyFactory::__invoke()   A

Complexity

Conditions 5
Paths 8

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
ccs 0
cts 11
cp 0
rs 9.6111
c 0
b 0
f 0
cc 5
nc 8
nop 3
crap 30
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2019 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Core\Queue\Strategy;
12
13
use Interop\Container\ContainerInterface;
14
use Psr\Log\NullLogger;
15
use Zend\Log\LoggerInterface;
16
use Zend\ServiceManager\Factory\FactoryInterface;
17
18
/**
19
 * Factory for \Core\Queue\Strategy\LogStrategy
20
 * 
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @todo write test  
23
 */
24
class LogStrategyFactory implements FactoryInterface
25
{
26
    
27
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
28
    {
29
        $log = isset($options['log']) ? $options['log'] : null;
30
31
        if ($log && $container->has($log)) {
32
            $log = $container->get($log);
33
        }
34
35
        if (!$log instanceOf LoggerInterface) {
36
            $log = null;
37
        }
38
39
        $service = new LogStrategy($log);
40
        
41
        return $service;    
42
    }
43
}
44