Completed
Push — master ( 04f4de...09f2a5 )
by Simone
02:25
created

Service   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 1
dl 0
loc 72
ccs 33
cts 33
cp 1
rs 10
c 0
b 0
f 0

12 Methods

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