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

        $comparator = function ($a, $b) {
            return $a === $b ? 0 : -1;
        };

        $diffAtoB = \array_udiff($this->data, $other->data, $comparator);
        $diffBtoA = \array_udiff($other->data, $this->data, $comparator);

        return new static(\array_merge($diffAtoB, $diffBtoA));
    }
public function diff(CollectionInterface $other): CollectionInterface
    {
        if (!$other instanceof static) {
            throw new CollectionMismatchException('Collection must be of type ' . static::class);
        }

        $comparator = function ($a, $b) {
            return $a === $b ? 0 : -1;
        };

        $diffAtoB = \array_udiff($this->data, $other->data, $comparator);
        $diffBtoA = \array_udiff($other->data, $this->data, $comparator);

        return new static(\array_merge($diffAtoB, $diffBtoA));
    }
public function diff ( CollectionInterface $ other ) : CollectionInterface { if ( ! $ other instanceof static ) { throw new CollectionMismatchException ( 'Collection must be of type ' . static :: class ) ; } $ comparator = function ( $ a , $ b ) { return $ a === $ b ? 0 : - 1 ; } ; $ diffAtoB = \ array_udiff ( $ this -> data , $ other -> data , $ comparator ) ; $ diffBtoA = \ array_udiff ( $ other -> data , $ this -> data , $ comparator ) ; return new static ( \ array_merge ( $ diffAtoB , $ diffBtoA ) ) ; }
Create a new collection with divergent items between current and given
collection.

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

@return self

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