TimerCollection::removeTimer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Dazzle\Loop\Timer;
4
5
class TimerCollection implements TimerCollectionInterface
6
{
7
    /**
8
     * @var TimerInterface[]
9
     */
10
    protected $timers;
11
12
    /**
13
     * @param TimerInterface[] $timers
14
     */
15 11
    public function __construct($timers = [])
16
    {
17 11
        $this->timers = [];
18
19 11
        foreach ($timers as $name=>$timer)
20
        {
21 3
            $this->addTimer($name, $timer);
22
        }
23 11
    }
24
25
    /**
26
     *
27
     */
28 11
    public function __destruct()
29
    {
30 11
        unset($this->timers);
31 11
    }
32
33
    /**
34
     * @override
35
     * @inheritDoc
36
     */
37 2
    public function getTimers()
38
    {
39 2
        return $this->timers;
40
    }
41
42
    /**
43
     * @override
44
     * @inheritDoc
45
     */
46 7
    public function existsTimer($name)
47
    {
48 7
        return isset($this->timers[$name]);
49
    }
50
51
    /**
52
     * @override
53
     * @inheritDoc
54
     */
55 6
    public function addTimer($name, TimerInterface $timer)
56
    {
57 6
        $this->timers[$name] = $timer;
58 6
    }
59
60
    /**
61
     * @override
62
     * @inheritDoc
63
     */
64 2
    public function getTimer($name)
65
    {
66 2
        return $this->existsTimer($name) ? $this->timers[$name] : null;
67
    }
68
69
    /**
70
     * @override
71
     * @inheritDoc
72
     */
73 2
    public function removeTimer($name)
74
    {
75 2
        unset($this->timers[$name]);
76 2
    }
77
}
78