1 | <?php |
||
10 | class ArraySet implements \IteratorAggregate, DatasetInterface { |
||
|
|||
11 | use Utils\DatasetTrait; |
||
12 | |||
13 | /** |
||
14 | * @var array The internal data array. |
||
15 | */ |
||
16 | private $data; |
||
17 | |||
18 | /** |
||
19 | * @var bool Indicates that the data needs to be sorted. |
||
20 | */ |
||
21 | private $toSort = false; |
||
22 | |||
23 | /** |
||
24 | * Construct a new {@link ArraySet} object. |
||
25 | * |
||
26 | * @param array|\Traversable $data The initial data in the array. |
||
27 | * @param string[] The default sort order. Supply this to prevent a manual sort. |
||
28 | */ |
||
29 | 4 | public function __construct($data = [], $order = []) { |
|
33 | |||
34 | /** |
||
35 | * Sort the internal array. |
||
36 | */ |
||
37 | 2 | protected function sortData() { |
|
62 | |||
63 | /** |
||
64 | * Get the underlying data array. |
||
65 | * |
||
66 | * @return array Returns the data. |
||
67 | */ |
||
68 | 3 | public function getData() { |
|
79 | |||
80 | /** |
||
81 | * Set the underlying data array. |
||
82 | * |
||
83 | * @param array|\Traversable $data |
||
84 | * @return $this |
||
85 | */ |
||
86 | 4 | public function setData($data) { |
|
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | 2 | public function setOrder(...$columns) { |
|
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | 1 | public function count() { |
|
128 | } |
||
129 |