1: <?php namespace mechanicious\Columnizer;
2:
3: use Illuminate\Support\Collection;
4:
5: class Column extends Collection
6: {
7: /**
8: * Yup, column is a collection as well!
9: */
10: protected $header = "";
11:
12: public function __construct(array $items = array(), $header)
13: {
14: parent::__construct($items);
15: $this->header = $header;
16: }
17:
18: /**
19: * Get the column header
20: *
21: * @return string
22: */
23: public function getHeader()
24: {
25: return $this->header;
26: }
27:
28: /**
29: * Remove last elements of an array
30: *
31: * @param int $amount
32: * @return mechanicious\Columnizer\Column
33: */
34: public function chop($amount = 1)
35: {
36: $endOffset = count($this->items) - $amount;
37: $slice = array_slice($this->items, 0, $endOffset, $preserveKeys = true);
38: $this->items = $slice;
39: return $this;
40: }
41: }