PropertyInjector   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 18
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A inject() 0 15 3
1
<?php
2
3
namespace DICIT\Injectors;
4
5
use DICIT\Injector;
6
use DICIT\Container;
7
8
class PropertyInjector implements Injector
9
{
10
    public function inject(Container $container, $service, array $serviceConfig)
11
    {
12
        $propConfig = array();
13
14
        if (array_key_exists('props', $serviceConfig)) {
15
            $propConfig = $serviceConfig['props'];
16
        }
17
18
        foreach($propConfig as $propName => $propValue) {
19
            $convertedValue = $container->resolve($propValue);
20
            $service->$propName = $convertedValue;
21
        }
22
23
        return true;
24
    }
25
}
26