12
12
class CurrentNextIterator implements \Iterator
13
13
{
14
14
15
- /**
16
- * Contains the items to iterate over
17
- *
18
- * @var array
19
- */
20
- private $ items = [];
15
+ /**
16
+ * Contains the items to iterate over
17
+ *
18
+ * @var array
19
+ */
20
+ private $ items = [];
21
21
22
- /**
23
- * Contains the current item (previous current) to compare with the next
24
- * @var mixed
25
- */
26
- private $ currentItem = null ;
22
+ /**
23
+ * Contains the current item (previous current) to compare with the next
24
+ * @var mixed
25
+ */
26
+ private $ currentItem = null ;
27
27
28
- /**
29
- * Contains the current key to compare with the current key
30
- * @var null
31
- */
32
- private $ currentKey = null ;
28
+ /**
29
+ * Contains the current key to compare with the current key
30
+ * @var null
31
+ */
32
+ private $ currentKey = null ;
33
33
34
- /**
35
- * Contains the next item (next current) to compare with the real current
36
- * @var mixed
37
- */
38
- private $ nextItem = null ;
34
+ /**
35
+ * Contains the next item (next current) to compare with the real current
36
+ * @var mixed
37
+ */
38
+ private $ nextItem = null ;
39
39
40
- /**
41
- * Contains the next key to compare with the current key
42
- * @var null
43
- */
44
- private $ nextKey = null ;
40
+ /**
41
+ * Contains the next key to compare with the current key
42
+ * @var null
43
+ */
44
+ private $ nextKey = null ;
45
45
46
- /**
47
- * @param array $data
48
- */
49
- public function __construct (array $ data ) {
50
- $ this ->items = $ data ;
51
- }
46
+ /**
47
+ * @param array $data
48
+ */
49
+ public function __construct (array $ data )
50
+ {
51
+ $ this ->items = $ data ;
52
+ }
52
53
53
- /**
54
- * @inheritedDoc
55
- */
56
- public function current () {
57
- return [
58
- 'current ' => $ this ->currentItem ,
59
- 'next ' => $ this ->nextItem
60
- ];
61
- }
54
+ /**
55
+ * @inheritedDoc
56
+ */
57
+ public function current ()
58
+ {
59
+ return [
60
+ 'current ' => $ this ->currentItem ,
61
+ 'next ' => $ this ->nextItem
62
+ ];
63
+ }
62
64
63
- /**
64
- * @inheritedDoc
65
- */
66
- public function next () {
67
- $ this -> currentItem = current ( $ this -> items );
68
- $ this ->currentKey = key ($ this ->items );
69
- next ($ this ->items );
70
- $ this -> nextItem = current ($ this ->items );
71
- $ this ->nextKey = key ($ this ->items );
72
- if ( $ this ->nextItem === false )
73
- {
74
- $ this ->nextItem = null ;
75
- $ this ->nextKey = null ;
76
- }
77
- }
65
+ /**
66
+ * @inheritedDoc
67
+ */
68
+ public function next ()
69
+ {
70
+ $ this ->currentItem = current ($ this ->items );
71
+ $ this -> currentKey = key ($ this ->items );
72
+ next ($ this ->items );
73
+ $ this ->nextItem = current ($ this ->items );
74
+ $ this ->nextKey = key ( $ this -> items );
75
+ if ( $ this -> nextItem === false ) {
76
+ $ this ->nextItem = null ;
77
+ $ this ->nextKey = null ;
78
+ }
79
+ }
78
80
79
- /**
80
- * @inheritedDoc
81
- */
82
- public function key () {
83
- return [
84
- 'previous ' => $ this ->currentKey ,
85
- 'current ' => $ this ->nextKey
86
- ];
87
- }
81
+ /**
82
+ * @inheritedDoc
83
+ */
84
+ public function key ()
85
+ {
86
+ return [
87
+ 'previous ' => $ this ->currentKey ,
88
+ 'current ' => $ this ->nextKey
89
+ ];
90
+ }
88
91
89
- /**
90
- * @inheritedDoc
91
- */
92
- public function valid () {
93
- return $ this ->currentKey !== null ;
94
- }
92
+ /**
93
+ * @inheritedDoc
94
+ */
95
+ public function valid ()
96
+ {
97
+ return $ this ->currentKey !== null ;
98
+ }
95
99
96
- /**
97
- * @inheritedDoc
98
- */
99
- public function rewind () {
100
- reset ( $ this -> items );
101
- $ this ->next ( );
102
- }
103
-
104
- }
100
+ /**
101
+ * @inheritedDoc
102
+ */
103
+ public function rewind ()
104
+ {
105
+ reset ( $ this ->items );
106
+ $ this -> next ();
107
+ }
108
+ }
0 commit comments