Passed
Branch version-2.0 (b3c55d)
by Sebastian
01:53
created

QueueTrait::dequeue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * Copyright (C) 2018 Sebastian Böttger <[email protected]>
4
 * You may use, distribute and modify this code under the
5
 * terms of the MIT license.
6
 *
7
 * You should have received a copy of the MIT license with
8
 * this file. If not, please visit: https://opensource.org/licenses/mit-license.php
9
 */
10
11
namespace Seboettg\Collection\Queue;
12
13
/**
14
 * Trait QueueTrait
15
 * @property $array Base array of this data structure
16
 * @package Seboettg\Collection\Queue
17
 */
0 ignored issues
show
Documentation Bug introduced by
The doc comment $array at position 0 could not be parsed: Unknown type name '$array' at position 0 in $array.
Loading history...
18
trait QueueTrait
19
{
20
21
    /**
22
     * @var array
23
     */
24
    protected $array;
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 3
    public function enqueue($item)
30
    {
31 3
        $this->array = array_merge([$item], $this->array);
32 3
        return $this;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 3
    public function dequeue()
39
    {
40 3
        return array_pop($this->array);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 2
    public function count()
47
    {
48 2
        return count($this->array);
49
    }
50
}
51