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

QueueTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A dequeue() 0 3 1
A enqueue() 0 4 1
A count() 0 3 1
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