| 1 | <?php |
||
| 19 | trait ElementStackable |
||
| 20 | { |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var \PhpCollection\Sequence |
||
| 24 | */ |
||
| 25 | protected $collection; |
||
| 26 | |||
| 27 | |||
| 28 | public function first() |
||
| 29 | { |
||
| 30 | $first = $this->collection->first(); |
||
| 31 | return $first->getOrElse(null); |
||
| 32 | } |
||
| 33 | |||
| 34 | public function last() |
||
| 35 | { |
||
| 36 | $last = $this->collection->last(); |
||
| 37 | return $last->getOrElse(null); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return array |
||
| 42 | */ |
||
| 43 | public function toArray() |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return int |
||
| 50 | */ |
||
| 51 | public function isEmpty() |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return int |
||
| 58 | */ |
||
| 59 | public function count() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return \ArrayIterator|\Traversable |
||
| 66 | */ |
||
| 67 | public function getIterator() |
||
| 71 | |||
| 72 | } |
||
| 73 |