public function intersect(CollectionInterface $other): CollectionInterface
    {
        if (!$other instanceof static) {
            throw new CollectionMismatchException('Collection must be of type ' . static::class);
        }

        $intersect = \array_uintersect($this->data, $other->data, function ($a, $b) {
            return $a === $b ? 0 : -1;
        });

        return new static($intersect);
    }
public function intersect(CollectionInterface $other): CollectionInterface
    {
        if (!$other instanceof static) {
            throw new CollectionMismatchException('Collection must be of type ' . static::class);
        }

        $intersect = \array_uintersect($this->data, $other->data, function ($a, $b) {
            return $a === $b ? 0 : -1;
        });

        return new static($intersect);
    }
public function intersect ( CollectionInterface $ other ) : CollectionInterface { if ( ! $ other instanceof static ) { throw new CollectionMismatchException ( 'Collection must be of type ' . static :: class ) ; } $ intersect = \ array_uintersect ( $ this -> data , $ other -> data , function ( $ a , $ b ) { return $ a === $ b ? 0 : - 1 ; } ) ; return new static ( $ intersect ) ; }
Create a new collection with intersecting item between current and given
collection.

@param CollectionInterface $other The collection to check for
intersecting items.

@return self

@throws CollectionMismatchException if the given collection is not of the
same type.
Create a new collection with intersecting item between current and given collection .