Test Setup Failed
Branch version-2.0 (c21687)
by Sebastian
04:11
created

QueueTrait::dequeue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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
     * {@inheritdoc}
22
     */
23
    public function enqueue($item)
24
    {
25
        $this->array = array_merge([$item], $this->array);
0 ignored issues
show
Bug Best Practice introduced by
The property array does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
        return $this;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function dequeue()
33
    {
34
        return array_pop($this->array);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function count()
41
    {
42
        return count($this->array);
43
    }
44
}
45