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

Service::isConstructorEmpty()   A

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 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