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