Issues (35)

src/Queue/QueueTrait.php (2 issues)

1
<?php
2
declare(strict_types=1);
3
/*
4
 * Copyright (C) 2018 Sebastian Böttger <[email protected]>
5
 * You may use, distribute and modify this code under the
6
 * terms of the MIT license.
7
 *
8
 * You should have received a copy of the MIT license with
9
 * this file. If not, please visit: https://opensource.org/licenses/mit-license.php
10
 */
11
12
namespace Seboettg\Collection\Queue;
13
14
/**
15
 * Trait QueueTrait
16
 * @property $array Base array of this data structure
17
 * @package Seboettg\Collection\Queue
18
 */
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...
19
trait QueueTrait
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 3
    public function enqueue($item)
25
    {
26 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...
27 3
        return $this;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 3
    public function dequeue()
34
    {
35 3
        return array_pop($this->array);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 2
    public function count(): int
42
    {
43 2
        return count($this->array);
44
    }
45
}
46