/** * @return int */ public function count() { if ($this->count === null) { $this->rewind(); $count = 0; while ($this->current) { $count++; $this->current = $this->current->getNext(); } $this->count = $count; } return $this->count; }