Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DoubleEndedQueue.php

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\Collection

Code

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;
}
RSS feed
Powered by Drupal