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

Breadcrumb

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

function AbstractCollection::intersect

Parameters

CollectionInterface<T> $other The collection to check for: intersecting items.

Return value

CollectionInterface<T>

Throws

CollectionMismatchException if the compared collections are of differing types.

Overrides CollectionInterface::intersect

File

vendor/ramsey/collection/src/AbstractCollection.php, line 285

Class

AbstractCollection
This class provides a basic implementation of `CollectionInterface`, to minimize the effort required to implement this interface

Namespace

Ramsey\Collection

Code

public function intersect(CollectionInterface $other) : CollectionInterface {
    $this->compareCollectionTypes($other);
    
    /** @var array<array-key, T> $intersect */
    $intersect = array_uintersect($this->data, $other->toArray(), $this->getComparator());
    $collection = clone $this;
    $collection->data = $intersect;
    return $collection;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal