Passed
Push — master ( c51b1a...8af9fd )
by Simone
02:14
created

Service::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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 6
    public function getClass()
34
    {
35 6
        $argument = Argument::fromString($this->params['name']);
36 6
        $serviceName = $argument->getServiceName();
37 6
        return $this->params['services'][$serviceName]['class'];
38
    }
39
40 2
    public function getServicesConfiguration()
41
    {
42 2
        return $this->params['services'];
43
    }
44
45 6
    public function getName()
46
    {
47 6
        return $this->params['name'];
48
    }
49
50 6
    public function hasMethodInjection()
51
    {
52 6
        return array() == $this->getMethods()
53 6
            && array() != $this->getParams();
54
    }
55
56 6
    public function hasSimpleInjection()
57
    {
58 6
        return array() != $this->getMethods()
59 6
            && array() == $this->getParams();
60
    }
61
62 6
    public function classNotExists()
63
    {
64 6
        return !class_exists($this->getClass());
65
    }
66
}
67