Completed
Push — master ( d1f44d...2f7083 )
by Kamil
02:59
created

Queue::isEmpty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Dazzle\MySQL\Support\Queue;
4
5
use Dazzle\Event\BaseEventEmitter;
6
use Dazzle\MySQL\Protocol\CommandInterface;
7
use SplQueue;
8
9
class Queue extends BaseEventEmitter implements QueueInterface
10
{
11
    /**
12
     * @var SplQueue
13
     */
14
    public $queue;
15
16
    /**
17
     *
18
     */
19
    public function __construct()
20
    {
21
        $this->queue = new SplQueue();
22
    }
23
24
    /**
25
     * @override
26
     * @inheritDoc
27
     */
28
    public function isEmpty()
29
    {
30
        return $this->queue->isEmpty();
31
    }
32
33
    /**
34
     * @override
35
     * @inheritDoc
36
     */
37
    public function enqueue(CommandInterface $command)
38
    {
39
        $this->queue->enqueue($command);
40
        $this->emit('new');
41
        return $command;
42
    }
43
44
    /**
45
     * @override
46
     * @inheritDoc
47
     */
48
    public function dequeue()
49
    {
50
        return $this->queue->dequeue();
51
    }
52
53
    /**
54
     * Unshift command.
55
     *
56
     * @return CommandInterface
57
     */
58
    public function unshift(CommandInterface $command)
59
    {
60
        $this->queue->unshift($command);
61
        return $command;
62
    }
63
}
64