Queue::flush()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php namespace Indatus\Dispatcher;
2
3
/**
4
 * This file is part of Dispatcher
5
 *
6
 * (c) Ben Kuhl <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
class Queue
13
{
14
    /** @var QueueItem[] */
15
    protected $queue = [];
16
17
    /**
18
     * Add an item to the queue
19
     * @param QueueItem $item
20
     */
21 2
    public function add(QueueItem $item)
22
    {
23 2
        $this->queue[] = $item;
24
25 2
        return true;
26
    }
27
28
    /**
29
     * The size of the queue
30
     * @return int
31
     */
32 1
    public function size()
33
    {
34 1
        return count($this->queue);
35
    }
36
37
    /**
38
     * Get all items in the queue
39
     * @return QueueItem[]
40
     */
41 1
    public function flush()
42
    {
43 1
        $queue = $this->queue;
44 1
        $this->queue = [];
45
46 1
        return $queue;
47
    }
48
}
49