protected function countWhileTrue(callable $condition) { $count = 0; foreach ($this->items as $item) { if (!$condition($item)) { break; } $count++; } return $count; }