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

ParameterWire::post()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
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