Completed
Push — master ( 390e4e...b0ec12 )
by Taosikai
12:57
created

Timer::activate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Timer;
7
8
use React\EventLoop\LoopInterface;
9
use React\EventLoop\Timer\TimerInterface as ReactTimer;
10
11
abstract class Timer implements TimerInterface
12
{
13
    /**
14
     * @var LoopInterface
15
     */
16
    protected $loop;
17
18
    /**
19
     * @var ReactTimer
20
     */
21
    protected $reactTimer;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function activate(LoopInterface $loop, ReactTimer $timer)
27
    {
28
        $this->loop = $loop;
29
        $this->reactTimer = $timer;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function cancel()
36
    {
37
        $this->loop->cancelTimer($this->reactTimer);
38
    }
39
}