Processor::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 3
nop 1
1
<?php
2
3
namespace Dafiti\Silex\Log\Factory;
4
5
class Processor extends AbstractFactory
6
{
7
    public function __invoke(array $args)
8
    {
9
        $this->args = $args;
10
11
        if (!isset($this->args['class']) || empty($this->args['class'])) {
12
            throw new \OutOfBoundsException('You should define key class to create a log processor');
13
        }
14
15
        $class = new \ReflectionClass($args['class']);
16
        $params = [];
17
18
        if ($constructor = $class->getConstructor()) {
19
            $params = $this->getParams($constructor);
20
        }
21
22
        return $class->newInstanceArgs($params);
23
    }
24
}
25