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

ParameterWire::injectParameter()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 9
rs 9.6666
c 1
b 0
f 0
cc 3
eloc 5
nc 3
nop 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