Completed
Push — master ( 448360...56edb4 )
by Simone
02:19
created

MethodResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setArgumentBuilder() 0 4 1
A resolve() 0 13 2
1
<?php
2
3
namespace Sensorario\Container\Resolver;
4
5
use ReflectionClass;
6
use Sensorario\Container\ArgumentBuilder;
7
use Sensorario\Container\Objects\Service;
8
9
class MethodResolver
10
{
11
    private $instances = array();
12
13
    private $builder;
14
15 9
    public function setArgumentBuilder(ArgumentBuilder $builder)
16
    {
17 9
        $this->builder = $builder;
18 9
    }
19
20 2
    public function resolve(Service $service)
21
    {
22 2
        $this->builder->setParams($service->getParams());
23
24 2
        $this->arguments = $this->builder->getArguments();
0 ignored issues
show
Bug introduced by
The property arguments does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
25
26 2
        if (!isset($this->instances[$service->getName()])) {
27 2
            $refObj = new ReflectionClass($service->getClass());
28 2
            $this->instances[$service->getName()] = $refObj->newInstanceArgs($this->arguments);
29 2
        }
30
31 2
        return $this->instances[$service->getName()];
32
    }
33
}
34