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