ArgumentBuilder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 37
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setContainer() 0 4 1
A setParams() 0 4 1
A getArguments() 0 20 4
1
<?php
2
3
namespace Sensorario\Container;
4
5
use Psr\Container\ContainerInterface;
6
7
class ArgumentBuilder
8
{
9
    private $container;
10
11
    private $params = [];
12
13 12
    public function setContainer(ContainerInterface $container) : void
14
    {
15 12
        $this->container = $container;
16 12
    }
17
18 3
    public function setParams(array $params) : void
19
    {
20 3
        $this->params = $params;
21 3
    }
22
23 5
    public function getArguments() : array
24
    {
25 5
        $arguments = [];
26
27 5
        if (!$this->container) {
28 1
            throw new \RuntimeException(
29 1
                'Oops! Container is not defined'
30
            );
31
        }
32
33 4
        foreach ($this->params as $param) {
34 3
            $parameter = Objects\Argument::fromString($param);
35
36 3
            $arguments[] = $parameter->isService()
37 3
                ? $this->container->get($param)
38 3
                : $param;
39
        }
40
41 4
        return $arguments;
42
    }
43
}
44