Passed
Pull Request — master (#2)
by Alessandro
02:10
created

Service   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 41
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A box() 0 4 1
A getParams() 0 4 1
A getClass() 0 6 1
A getName() 0 4 1
A classNotExists() 0 4 1
A isConstructorEmpty() 0 4 1
1
<?php
2
3
namespace Sensorario\Container\Objects;
4
5
class Service
6
{
7
    private $params;
8
9 4
    private function __construct(array $params)
10
    {
11 4
        $this->params = $params;
12 4
    }
13
14 4
    public static function box(array $params)
15
    {
16 4
        return new self($params);
17
    }
18
19 4
    public function getParams()
20
    {
21 4
        return $this->params['services'][$this->getName()]['params'] ?? [];
22
    }
23
24 3
    public function getClass()
25
    {
26 3
        $argument = Argument::fromString($this->params['name']);
27 3
        $serviceName = $argument->getServiceName();
28 3
        return $this->params['services'][$serviceName]['class'];
29
    }
30
31 4
    public function getName()
32
    {
33 4
        return $this->params['name'];
34
    }
35
36 4
    public function isConstructorEmpty()
37
    {
38 4
        return [] == $this->getParams();
39
    }
40
41 3
    public function classNotExists()
42
    {
43 3
        return !class_exists($this->getClass());
44
    }
45
}
46