Passed
Push — master ( 9a224a...3e0fbd )
by Sebastian
02:02
created

QueueTrait::count()   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
     * {@inheritdoc}
22
     */
23 3
    public function enqueue($item)
24
    {
25 3
        $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 3
        return $this;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 3
    public function dequeue()
33
    {
34 3
        return array_pop($this->array);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 2
    public function count()
41
    {
42 2
        return count($this->array);
43
    }
44
}
45