-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraitIteratorCountableEmpty.php
More file actions
43 lines (39 loc) · 937 Bytes
/
traitIteratorCountableEmpty.php
File metadata and controls
43 lines (39 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* This trait implements the methods for an empty, countable Iterator.
*
* Use this for a class that needs to fulfill both the Countable and
* the Iterator interfaces, but will always be empty (aka contain no
* objects in the Iterator and count() returning 0):
*
* <code>
* class MyEmptyIterator implements Iterator, Countable {
* use traitIteratorCountableEmpty;
* }
* </code>
*
* Just saves you some typing for Mock-Ups, test cases, or other
* classes that will never contain anything.
*
* @author Beat Vontobel
* @since 2015-04-01
* @package MeteoNews\phplib
* @subpackage Iterators
*/
trait traitIteratorCountableEmpty {
public function count() {
return 0;
}
public function valid() {
return FALSE;
}
public function current() {
return NULL;
}
public function key() {
return NULL;
}
public function next() { }
public function rewind() { }
}
?>