public function valid() { $valid = $this->iterator->valid(); if (!$valid) { $this->closeCursor(); } return $valid; }