CallbackTask   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 93
c 0
b 0
f 0
wmc 8
lcom 1
cbo 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A serialize() 0 6 1
A unserialize() 0 7 1
A getData() 0 6 1
A getHandler() 0 4 1
A ignoresRules() 0 4 1
A stopsSiblings() 0 4 1
A canRunTask() 0 4 1
1
<?php
2
3
namespace AsyncPHP\Doorman\Task;
4
5
use AsyncPHP\Doorman\Task;
6
use Closure;
7
use Jeremeamia\SuperClosure\SerializableClosure;
8
9
class CallbackTask implements Task
10
{
11
    /**
12
     * @var Closure
13
     */
14
    protected $closure;
15
16
    /**
17
     * @param Closure $closure
18
     */
19
    public function __construct(Closure $closure)
20
    {
21
        $this->closure = $closure;
22
    }
23
24
    /**
25
     * @inheritdoc
26
     *
27
     * @return string
28
     */
29
    public function serialize()
30
    {
31
        $closure = new SerializableClosure($this->closure);
32
33
        return serialize($closure);
34
    }
35
36
    /**
37
     * @inheritdoc
38
     *
39
     * @param string $serialized
40
     */
41
    public function unserialize($serialized)
42
    {
43
        /** @var SerializableClosure $closure */
44
        $closure = unserialize($serialized);
45
46
        $this->closure = $closure->getClosure();
47
    }
48
49
    /**
50
     * @inheritdoc
51
     *
52
     * @return array
53
     */
54
    public function getData()
55
    {
56
        return array(
57
            "closure" => $this->closure,
58
        );
59
    }
60
61
    /**
62
     * @inheritdoc
63
     *
64
     * @return string
65
     */
66
    public function getHandler()
67
    {
68
        return "AsyncPHP\\Doorman\\Handler\\CallbackHandler";
69
    }
70
71
    /**
72
     * @inheritdoc
73
     *
74
     * @return bool
75
     */
76
    public function ignoresRules()
77
    {
78
        return false;
79
    }
80
81
    /**
82
     * @inheritdoc
83
     *
84
     * @return bool
85
     */
86
    public function stopsSiblings()
87
    {
88
        return false;
89
    }
90
91
    /**
92
     * @inheritdoc
93
     * 
94
     * @return bool
95
     */
96
    public function canRunTask()
97
    {
98
        return true;
99
    }
100
101
}
102