array = $array; } elseif ( is_object( $array ) ) { $this->array = get_object_vars( $array ); } else { throw new InvalidArgumentException( __METHOD__ . ' requires an array or object' ); } $this->rewind(); } public function current() { return current( $this->array ); } public function key() { return key( $this->array ); } public function next() { prev( $this->array ); } public function rewind() { end( $this->array ); } public function valid() { return key( $this->array ) !== null; } public function count() { return count( $this->array ); } }