1 | <?php |
||
21 | class TabularCollection extends MultiCollection |
||
22 | { |
||
23 | /** |
||
24 | * Is input data structure valid? |
||
25 | * |
||
26 | * In order to determine whether a given data structure is valid for a |
||
27 | * particular collection type (tabular, numeric, etc.), we have this method. |
||
28 | * |
||
29 | * @param mixed $data The data structure to check |
||
30 | * @return boolean True if data structure is tabular |
||
31 | */ |
||
32 | 40 | protected function isConsistentDataStructure($data) |
|
36 | |||
37 | /** |
||
38 | * Does this collection have specified column? |
||
39 | * |
||
40 | * @param mixed $column The column index |
||
41 | * @return bool |
||
42 | */ |
||
43 | 8 | public function hasColumn($column) |
|
44 | { |
||
45 | try { |
||
46 | 8 | $this->getColumn($column); |
|
47 | 8 | return true; |
|
48 | 1 | } catch (OutOfBoundsException $e) { |
|
49 | 1 | return false; |
|
50 | } |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get column as collection |
||
55 | * |
||
56 | * @param mixed $column The column index |
||
57 | * @param bool $throw Throw an exception on failure |
||
58 | * @return AbstractCollection|false |
||
59 | */ |
||
60 | public function getColumn($column, $throw = true) |
||
71 | |||
72 | /** |
||
73 | * Does this collection have a row at specified index? |
||
74 | * |
||
75 | * @param int $offset The column index |
||
76 | * @return bool |
||
77 | */ |
||
78 | public function hasRow($offset) |
||
87 | |||
88 | /** |
||
89 | * Get row at specified index. |
||
90 | * |
||
91 | * @param int $offset The row offset (starts from 0) |
||
92 | * @param bool $throw Whether or not to throw an exception if row does not exist |
||
93 | * |
||
94 | * @return AbstractCollection|false |
||
95 | */ |
||
96 | public function getRow($offset, $throw = true) |
||
100 | |||
101 | /** |
||
102 | * @inheritdoc |
||
103 | */ |
||
104 | 1 | public function map(callable $callback) |
|
112 | |||
113 | /** |
||
114 | * @inheritdoc |
||
115 | */ |
||
116 | 21 | public function walk(callable $callback, $extraContext = null) |
|
123 | |||
124 | // public function average($column) |
||
125 | // { |
||
126 | // $coll = $this->getColumnAsCollection($column); |
||
127 | // return $coll->sum() / $coll->count(); |
||
128 | // } |
||
129 | // |
||
130 | // public function mode($column) |
||
131 | // { |
||
132 | // return $this->getColumnAsCollection($column)->mode(); |
||
133 | // } |
||
134 | // |
||
135 | // public function sum($column) |
||
136 | // { |
||
137 | // return $this->getColumnAsCollection($column)->sum(); |
||
138 | // } |
||
139 | // |
||
140 | // public function median($column) |
||
141 | // { |
||
142 | // return $this->getColumnAsCollection($column)->median(); |
||
143 | // } |
||
144 | // |
||
145 | // protected function getColumnAsCollection($column) |
||
146 | // { |
||
147 | // return static::factory(array_column($this->data, $column)); |
||
148 | // } |
||
149 | |||
150 | /** |
||
151 | * Magic method call |
||
152 | * |
||
153 | * @param string $method The name of the method |
||
154 | * @param array $args The argument list |
||
155 | * |
||
156 | * @throws BadMethodCallException If no method exists |
||
157 | * |
||
158 | * @return mixed |
||
159 | * |
||
160 | * @todo Add phpdoc comments for dynamic methods |
||
161 | * @todo throw BadMethodCallException |
||
162 | */ |
||
163 | 8 | public function __call($method, $args) |
|
174 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.