Completed
Push — master ( 208489...9bf66d )
by Park Jong-Hun
08:40
created

ParameterWire   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 27
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A appendParameter() 0 7 1
A injectParameter() 0 9 3
A post() 0 4 1
1
<?php
2
3
namespace Core;
4
5
use Prob\Handler\ParameterMap;
6
use Prob\Handler\ParameterInterface;
7
8
class ParameterWire
9
{
10
    private static $parameters = [];
11
12
    public static function appendParameter(ParameterInterface $key, $value)
13
    {
14
        self::$parameters[] = [
15
            'key' => $key,
16
            'value' => $value
17
        ];
18
    }
19
20
    public static function injectParameter(ParameterMap $map)
21
    {
22
        foreach (self::$parameters as $v) {
23
            $value = $v['value'] instanceof LazyWiringParameter ? $v['value']->exec() : $v['value'];
24
            $map->bindBy($v['key'], $value);
25
        }
26
27
        return $map;
28
    }
29
30
    public static function post(callable $parameter)
31
    {
32
        return new LazyWiringParameter($parameter);
33
    }
34
}
35