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