RuleHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 47
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __destruct() 0 4 1
A __invoke() 0 14 1
1
<?php
2
3
namespace Dazzle\Channel\Router\RuleHandle;
4
5
use Dazzle\Channel\Protocol\ProtocolInterface;
6
7
class RuleHandler
8
{
9
    /**
10
     * @var callable
11
     */
12
    protected $callback;
13
14
    /**
15
     * @param callable $callback
16
     */
17
    public function __construct(callable $callback)
18
    {
19
        $this->callback = $callback;
20
    }
21
22
    /**
23
     *
24
     */
25
    public function __destruct()
26
    {
27
        unset($this->callback);
28
    }
29
30
    /**
31
     * @param string $alias
32
     * @param ProtocolInterface $protocol
33
     * @param int $flags
34
     * @param callable|null $success
35
     * @param callable|null $failure
36
     * @param callable|null $cancel
37
     * @param float $timeout
38
     */
39
    public function __invoke($alias, ProtocolInterface $protocol, $flags, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0)
40
    {
41
        $callback = $this->callback;
42
43
        return $callback([
44
            'alias'    => $alias,
45
            'protocol' => $protocol,
46
            'flags'    => $flags,
47
            'success'  => $success,
48
            'failure'  => $failure,
49
            'cancel'   => $cancel,
50
            'timeout'  => $timeout
51
        ]);
52
    }
53
}
54