function AbstractCollection::first
Return value
T
Throws
NoSuchElementException if this collection is empty.
Overrides CollectionInterface::first
File
-
vendor/
ramsey/ collection/ src/ AbstractCollection.php, line 127
Class
- AbstractCollection
- This class provides a basic implementation of `CollectionInterface`, to minimize the effort required to implement this interface
Namespace
Ramsey\CollectionCode
public function first() : mixed {
$firstIndex = array_key_first($this->data);
if ($firstIndex === null) {
throw new NoSuchElementException('Can\'t determine first item. Collection is empty');
}
return $this->data[$firstIndex];
}