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
![]() |
|||
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
|
|||
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 |