1 | <?php |
||
37 | abstract class AbstractRow implements Iterator, Countable, ArrayAccess |
||
38 | { |
||
39 | /** |
||
40 | * An array of fields for this row |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $fields; |
||
44 | |||
45 | /** |
||
46 | * Iterator position |
||
47 | * @var int |
||
48 | */ |
||
49 | protected $position; |
||
50 | |||
51 | /** |
||
52 | * Class constructor |
||
53 | * |
||
54 | * @param array|Iterator An array (or anything that looks like one) of data (fields) |
||
55 | * @access public |
||
56 | */ |
||
57 | 63 | public function __construct($fields) |
|
62 | |||
63 | 63 | protected function setFields($fields) |
|
77 | |||
78 | 1 | public function __toString() |
|
82 | |||
83 | /** |
||
84 | * Join fields together using specified delimiter |
||
85 | * |
||
86 | * @param char The delimiter character |
||
87 | * @return string |
||
88 | * @access public |
||
89 | */ |
||
90 | 17 | public function join($delimiter = ',') |
|
94 | |||
95 | /** |
||
96 | * Convert object to an array |
||
97 | * |
||
98 | * @return array representation of the object |
||
99 | * @access public |
||
100 | */ |
||
101 | 28 | public function toArray() |
|
105 | |||
106 | /** Begin SPL Countable Interface Method **/ |
||
107 | |||
108 | /** |
||
109 | * Count fields within the row |
||
110 | * |
||
111 | * @return integer The amount of fields |
||
112 | * @access public |
||
113 | */ |
||
114 | 23 | public function count() |
|
118 | |||
119 | /** Begin SPL Iterator Interface Methods **/ |
||
120 | |||
121 | /** |
||
122 | * Get the current column's data object |
||
123 | * |
||
124 | * @return string |
||
125 | * @access public |
||
126 | */ |
||
127 | 61 | public function current() |
|
131 | |||
132 | /** |
||
133 | * Get the current key (column number or header, if available) |
||
134 | * |
||
135 | * @return string The "current" key |
||
136 | * @access public |
||
137 | * @todo Figure out if this can return a CSVelte\Table\HeaderData object so long as it |
||
138 | * has a __toString() method that generated the right key... |
||
139 | */ |
||
140 | public function key() |
||
144 | |||
145 | /** |
||
146 | * Advance the internal pointer to the next column's data object |
||
147 | * Also returns the next column's data object if there is one |
||
148 | * |
||
149 | * @return CSVelte\Table\Data The "next" column's data |
||
150 | * @access public |
||
151 | */ |
||
152 | 9 | public function next() |
|
157 | |||
158 | /** |
||
159 | * Return the internal pointer to the first column and return that object |
||
160 | * |
||
161 | * @return void |
||
162 | * @access public |
||
163 | */ |
||
164 | 62 | public function rewind() |
|
165 | { |
||
166 | 62 | $this->position = 0; |
|
167 | 62 | if ($this->valid()) return $this->current(); |
|
168 | 1 | } |
|
169 | |||
170 | /** |
||
171 | * Is the current position within the row's data fields valid? |
||
172 | * |
||
173 | * @return boolean |
||
174 | * @access public |
||
175 | */ |
||
176 | 62 | public function valid() |
|
180 | |||
181 | /** Begin SPL ArrayAccess Methods **/ |
||
182 | |||
183 | /** |
||
184 | * Is there an offset at specified position |
||
185 | * |
||
186 | * @param integer Offset |
||
187 | * @return boolean |
||
188 | * @access public |
||
189 | */ |
||
190 | 2 | public function offsetExists($offset) |
|
194 | |||
195 | /** |
||
196 | * Retrieve offset at specified position or by header name |
||
197 | * |
||
198 | * @param integer|string Offset/index |
||
199 | * @return CSVelte\Table\Data |
||
200 | * @access public |
||
201 | */ |
||
202 | 1 | public function offsetGet($offset) |
|
206 | |||
207 | /** |
||
208 | * Set offset at specified position |
||
209 | * |
||
210 | * @param integer|string Offset/index |
||
211 | * @param CSVelte\Table\Data |
||
212 | * @return void |
||
213 | * @access public |
||
214 | * @throws CSVelte\Exception\ImmutableException |
||
215 | */ |
||
216 | 3 | public function offsetSet($offset, $value) |
|
221 | |||
222 | /** |
||
223 | * Unset offset at specified position/index |
||
224 | * |
||
225 | * @param integer|string Offset/index |
||
226 | * @return void |
||
227 | * @access public |
||
228 | * @throws CSVelte\Exception\ImmutableException |
||
229 | * @todo I'm not sure if these objects will stay immutable or not yet... |
||
230 | */ |
||
231 | 2 | public function offsetUnset($offset) |
|
235 | |||
236 | /** |
||
237 | * Raise (throw) immutable exception |
||
238 | * |
||
239 | * @param string Message |
||
240 | * @return void |
||
241 | * @access protected |
||
242 | * @throws CSVelte\Exception\ImmutableException |
||
243 | */ |
||
244 | 4 | protected function raiseImmutableException($msg = null) |
|
249 | } |
||
250 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..