Queue   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 37
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 6 1
A size() 0 4 1
A flush() 0 7 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