public function mergeWith(Collection $collection): Collection
    {
        $calledClass = get_called_class();

        if ($collection instanceof $calledClass) {
            foreach ($collection as $key => $object) {
                $this[$key] = $object;
            }
        } else {
            throw new \InvalidArgumentException(sprintf('%s::mergeWith() method require an same type of Collection.', get_class($this)));
        }

        return $this;
    }
public function mergeWith(Collection $collection): Collection
    {
        $calledClass = get_called_class();

        if ($collection instanceof $calledClass) {
            foreach ($collection as $key => $object) {
                $this[$key] = $object;
            }
        } else {
            throw new \InvalidArgumentException(sprintf('%s::mergeWith() method require an same type of Collection.', get_class($this)));
        }

        return $this;
    }
public function mergeWith ( Collection $ collection ) : Collection { $ calledClass = get_called_class ( ) ; if ( $ collection instanceof $ calledClass ) { foreach ( $ collection as $ key => $ object ) { $ this [ $ key ] = $ object ; } } else { throw new \ InvalidArgumentException ( sprintf ( '%s::mergeWith() method require an same type of Collection.' , get_class ( $ this ) ) ) ; } return $ this ; }
Merge another Collection with this.

@param \Berlioz\Core\Entity\Collection $collection Collection to merge

@return static
@throws \InvalidArgumentException if not the same Collection class
Merge another Collection with this .