1212
1313namespace  chillerlan \Database ;
1414
15- use  ArrayAccess , Countable , Iterator ;
16- use  chillerlan \Database \Traits \{Enumerable , Magic };
15+ use  ArrayAccess , Countable , SeekableIterator ;
16+ use  chillerlan \Traits \{
17+ 	Enumerable , Magic , Interfaces \ArrayAccessTrait , SPL \SeekableIteratorTrait , SPL \CountableTrait 
18+ };
1719
1820/** 
1921 * @property int $length 
2022 * 
2123 * each($func [, $fieldname) 
2224 */ 
23- class  Result implements  Iterator , ArrayAccess, Countable{
24- 	use  Enumerable,  Magic;
25+ class  Result implements  SeekableIterator , ArrayAccess, Countable{
26+ 	use  ArrayAccessTrait, SeekableIteratorTrait, CountableTrait,  Magic, Enumerable ;
2527
2628	/** 
2729	 * @var \chillerlan\Database\ResultRow[] 
@@ -52,11 +54,11 @@ class Result implements Iterator, ArrayAccess, Countable{
5254	 * 
5355	 * @throws \chillerlan\Database\ConnectionException 
5456	 */ 
55- 	public  function  __construct ($ datanull , $ sourceEncodingnull , $ destEncoding' UTF-8 ' 
57+ 	public  function  __construct ($ datanull , string   $ sourceEncodingnull , string   $ destEncodingnull ){
5658		$ this sourceEncoding  = $ sourceEncoding
57- 		$ this destEncoding    = $ destEncoding
59+ 		$ this destEncoding    = $ destEncoding ??  ' UTF-8 ' 
5860
59- 		if (is_null ( $ data) ){
61+ 		if ($ data ===  null ){
6062			$ data
6163		}
6264		else  if ($ datainstanceof  \Traversable){
@@ -130,24 +132,6 @@ protected function magic_get_length():int{
130132	 * ArrayAccess * 
131133	 ***************/ 
132134
133- 	/** 
134- 	 * @param int|string $offset 
135- 	 * 
136- 	 * @return bool 
137- 	 */ 
138- 	public  function  offsetExists ($ offsetbool {
139- 		return  isset ($ this array [$ offset
140- 	}
141- 
142- 	/** 
143- 	 * @param int|string $offset 
144- 	 * 
145- 	 * @return \chillerlan\Database\ResultRow|mixed|null 
146- 	 */ 
147- 	public  function  offsetGet ($ offset
148- 		return  $ this array [$ offsetnull ;
149- 	}
150- 
151135	/** 
152136	 * @param int|string   $offset 
153137	 * @param array        $value 
@@ -165,65 +149,4 @@ public function offsetSet($offset, $value){
165149
166150	}
167151
168- 	/** 
169- 	 * @param int|string $offset 
170- 	 * 
171- 	 * @return void 
172- 	 */ 
173- 	public  function  offsetUnset ($ offset
174- 		unset($ this array [$ offset
175- 	}
176- 
177- 
178- 	/************* 
179- 	 * Countable * 
180- 	 *************/ 
181- 
182- 	/** 
183- 	 * @return int 
184- 	 */ 
185- 	public  function  count ():int {
186- 		return  count ($ this array );
187- 	}
188- 
189- 
190- 	/************ 
191- 	 * Iterator * 
192- 	 ************/ 
193- 
194- 	/** 
195- 	 * @return \chillerlan\Database\ResultRow|mixed 
196- 	 */ 
197- 	public  function  current (){
198- 		return  $ this offsetGet ($ this offset );
199- 	}
200- 
201- 	/** 
202- 	 * @return int 
203- 	 */ 
204- 	public  function  key ():int {
205- 		return  $ this offset ;
206- 	}
207- 
208- 	/** 
209- 	 * @return bool 
210- 	 */ 
211- 	public  function  valid ():bool {
212- 		return  $ this offsetExists ($ this offset );
213- 	}
214- 
215- 	/** 
216- 	 *  @return void 
217- 	 */ 
218- 	public  function  next (){
219- 		$ this offset ++;
220- 	}
221- 
222- 	/** 
223- 	 * @return void 
224- 	 */ 
225- 	public  function  rewind (){
226- 		$ this offset  = 0 ;
227- 	}
228- 
229152}
0 commit comments