function DoubleEndedQueue::addFirst
Throws
InvalidArgumentException if $element is of the wrong type
Overrides DoubleEndedQueueInterface::addFirst
1 call to DoubleEndedQueue::addFirst()
- DoubleEndedQueue::offerFirst in vendor/
ramsey/ collection/ src/ DoubleEndedQueue.php - Inserts the specified element at the front of this queue if it is possible to do so immediately without violating capacity restrictions.
File
-
vendor/
ramsey/ collection/ src/ DoubleEndedQueue.php, line 49
Class
- DoubleEndedQueue
- This class provides a basic implementation of `DoubleEndedQueueInterface`, to minimize the effort required to implement this interface.
Namespace
Ramsey\CollectionCode
public function addFirst(mixed $element) : bool {
if ($this->checkType($this->getType(), $element) === false) {
throw new InvalidArgumentException('Value must be of type ' . $this->getType() . '; value is ' . $this->toolValueToString($element));
}
array_unshift($this->data, $element);
return true;
}