Service::hasParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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) : self
15
    {
16 6
        return new self($params);
17
    }
18
19 6
    public function hasParams() : bool
20
    {
21 6
        return isset($this->params['services'][$this->getName()]['params']);
22
    }
23
24 6
    public function getParams() : array
25
    {
26 6
        return $this->hasParams()
27 2
            ? $this->params['services'][$this->getName()]['params']
28 6
            : [];
29
    }
30
31 6
    public function hasMethods() : bool
32
    {
33 6
        return isset($this->params['services'][$this->getName()]['methods']);
34
    }
35
36 6
    public function getMethods() : array
37
    {
38 6
        return $this->hasMethods()
39 2
            ? $this->params['services'][$this->getName()]['methods']
40 6
            : [];
41
    }
42
43 6
    public function getClass() : string
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() : array
51
    {
52 2
        return $this->params['services'];
53
    }
54
55 6
    public function getName() : string
56
    {
57 6
        return $this->params['name'];
58
    }
59
60 6
    public function hasMethodInjection() : bool
61
    {
62 6
        return [] == $this->getMethods()
63 6
            && [] != $this->getParams();
64
    }
65
66 6
    public function hasSimpleInjection() : bool
67
    {
68 6
        return [] != $this->getMethods()
69 6
            && [] == $this->getParams();
70
    }
71
72 6
    public function classNotExists() : bool
73
    {
74 6
        return !class_exists($this->getClass());
75
    }
76
}
77