Total Complexity | 6 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
19 | trait StackTrait |
||
20 | { |
||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | 4 | public function push($item) |
|
25 | { |
||
26 | 4 | $this->array[] = $item; |
|
27 | 4 | return $this; |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | 1 | public function pop() |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | 1 | public function peek() |
|
42 | { |
||
43 | 1 | return end($this->array); |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 1 | public function search($element) |
|
50 | { |
||
51 | 1 | $pos = array_search($element, $this->array); |
|
52 | 1 | if ($pos === false) { |
|
53 | 1 | return 0; |
|
54 | } |
||
55 | 1 | $count = $this->count(); |
|
56 | 1 | return $count - $pos; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | 4 | public function count() |
|
65 | } |
||
66 | } |
||
67 |