MediaWiki
REL1_34
ReverseArrayIterator.php
Go to the documentation of this file.
1
<?php
29
class
ReverseArrayIterator
implements
Iterator, Countable {
31
protected
$array
;
32
41
public
function
__construct
(
$array
= [] ) {
42
if
( is_array(
$array
) ) {
43
$this->array =
$array
;
44
} elseif ( is_object(
$array
) ) {
45
$this->array = get_object_vars(
$array
);
46
}
else
{
47
throw
new
InvalidArgumentException( __METHOD__ .
' requires an array or object'
);
48
}
49
50
$this->
rewind
();
51
}
52
53
public
function
current
() {
54
return
current
( $this->array );
55
}
56
57
public
function
key
() {
58
return
key
( $this->array );
59
}
60
61
public
function
next
() {
62
prev( $this->array );
63
}
64
65
public
function
rewind
() {
66
end( $this->array );
67
}
68
69
public
function
valid
() {
70
return
key
( $this->array ) !==
null
;
71
}
72
73
public
function
count
() {
74
return
count
( $this->array );
75
}
76
}
ReverseArrayIterator
Convenience class for iterating over an array in reverse order.
Definition
ReverseArrayIterator.php:29
ReverseArrayIterator\rewind
rewind()
Definition
ReverseArrayIterator.php:65
ReverseArrayIterator\key
key()
Definition
ReverseArrayIterator.php:57
ReverseArrayIterator\valid
valid()
Definition
ReverseArrayIterator.php:69
ReverseArrayIterator\next
next()
Definition
ReverseArrayIterator.php:61
ReverseArrayIterator\$array
$array
Definition
ReverseArrayIterator.php:31
ReverseArrayIterator\count
count()
Definition
ReverseArrayIterator.php:73
ReverseArrayIterator\current
current()
Definition
ReverseArrayIterator.php:53
ReverseArrayIterator\__construct
__construct( $array=[])
Creates an iterator which will visit the keys in $array in reverse order.
Definition
ReverseArrayIterator.php:41
includes
libs
ReverseArrayIterator.php
Generated on Fri Apr 5 2024 23:10:12 for MediaWiki by
1.9.8