Invoker   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 73
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A __destruct() 0 4 1
A call() 0 4 1
A existsProxy() 0 4 1
A setProxy() 0 4 1
A removeProxy() 0 4 1
A getProxy() 0 4 2
1
<?php
2
3
namespace Dazzle\Util\Invoker;
4
5
class Invoker implements InvokerInterface
6
{
7
    /**
8
     * @var callable[]
9
     */
10
    protected $proxies;
11
12
    /**
13
     * @param callable[] $proxies
14
     */
15 10
    public function __construct($proxies = [])
16
    {
17 10
        $this->proxies = [];
18
19 10
        foreach ($proxies as $func=>$proxy)
20
        {
21 1
            $this->setProxy($func, $proxy);
22
        }
23 10
    }
24
25
    /**
26
     *
27
     */
28 10
    public function __destruct()
29
    {
30 10
        unset($this->proxies);
31 10
    }
32
33
    /**
34
     * @override
35
     * @inheritDoc
36
     */
37 2
    public function call($func, $args = [])
38
    {
39 2
        return call_user_func_array($this->getProxy($func), $args);
40
    }
41
42
    /**
43
     * @override
44
     * @inheritDoc
45
     */
46 5
    public function existsProxy($func)
47
    {
48 5
        return isset($this->proxies[$func]);
49
    }
50
51
    /**
52
     * @override
53
     * @inheritDoc
54
     */
55 6
    public function setProxy($func, $callable)
56
    {
57 6
        $this->proxies[$func] = $callable;
58 6
    }
59
60
    /**
61
     * @override
62
     * @inheritDoc
63
     */
64 1
    public function removeProxy($func)
65
    {
66 1
        unset($this->proxies[$func]);
67 1
    }
68
69
    /**
70
     * @override
71
     * @inheritDoc
72
     */
73 3
    public function getProxy($func)
74
    {
75 3
        return isset($this->proxies[$func]) ? $this->proxies[$func] : $func;
76
    }
77
}
78