LoggersFactory::create()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 2
crap 3
1
<?php
2
3
namespace ElasticsearchModule\Service;
4
5
use ArrayObject;
6
use Interop\Container\ContainerInterface;
7
8
/**
9
 * @author Pedro Alves <[email protected]>
10
 */
11
class LoggersFactory extends AbstractFactory
12
{
13
    
14
    /**
15
     * {@inheritDoc}
16
     */
17 24
    protected function create(ContainerInterface $container, $config)
18
    {
19 24
        $factories = $config['factories'];
20 24
        $loggers = [];
21
        
22 24
        foreach ($factories as $name => $factory) {
23 24
            if (in_array(AbstractFactory::class, class_parents($factory))) {
24 24
                $factory = new $factory($this->getName());
25 24
                $loggers[$name] = $factory->create($container, $config);
26 24
            }
27 24
        }
28 24
        return new ArrayObject($loggers);
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     */
34 24
    public function getServiceType()
35
    {
36 24
        return 'loggers';
37
    }
38
39
}
40