public function count() { if ($this->elements instanceof \Countable) { return $this->elements->count(); } $count = 0; foreach ($this->elements as $value) { $count++; } return $count; }