Completed
Push — master ( e0cdcf...eeff10 )
by Simone
02:17
created

Service   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 93.55%

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 1
dl 0
loc 67
ccs 29
cts 31
cp 0.9355
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A box() 0 4 1
A getParams() 0 6 2
A getMethods() 0 6 2
A getClass() 0 6 1
A getServicesConfiguration() 0 4 1
A getName() 0 4 1
A isConstructorInjection() 0 5 2
A isMethodInjection() 0 5 2
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 6
    private function __construct(array $params)
10
    {
11 6
        $this->params = $params;
12 6
    }
13
14 6
    public static function box(array $params)
15
    {
16 6
        return new self($params);
17
    }
18
19 6
    public function getParams()
20
    {
21 6
        return isset($this->params['services'][$this->getName()]['params'])
22 6
            ? $this->params['services'][$this->getName()]['params']
23 6
            : array();
24
    }
25
26 6
    public function getMethods()
27
    {
28 6
        return isset($this->params['services'][$this->getName()]['methods'])
29 6
            ? $this->params['services'][$this->getName()]['methods']
30 6
            : array();
31
    }
32
33 5
    public function getClass()
34
    {
35 5
        $argument = Argument::fromString($this->params['name']);
36 5
        $serviceName = $argument->getServiceName();
37 5
        return $this->params['services'][$serviceName]['class'];
38
    }
39
40 1
    public function getServicesConfiguration()
41
    {
42 1
        return $this->params['services'];
43
    }
44
45 6
    public function getName()
46
    {
47 6
        return $this->params['name'];
48
    }
49
50
    public function isConstructorEmpty()
51
    {
52
        return array() == $this->getParams();
53
    }
54
55 6
    public function isConstructorInjection()
56
    {
57 6
        return array() == $this->getMethods()
58 6
            && array() != $this->getParams();
59
    }
60
61 5
    public function isMethodInjection()
62
    {
63 5
        return array() != $this->getMethods()
64 5
            && array() == $this->getParams();
65
    }
66
67 5
    public function classNotExists()
68
    {
69 5
        return !class_exists($this->getClass());
70
    }
71
}
72