Nelmio\Alice\ObjectBag::mergeWith PHP Method

mergeWith() public method

Creates a new instance with the new objects. If objects with the same reference already exists, they will be overridden by the new ones.
public mergeWith ( self $objects ) : self
$objects self
return self
    public function mergeWith(self $objects) : self
    {
        $clone = clone $this;
        foreach ($objects->objects as $reference => $object) {
            $clone->objects[$reference] = $object;
            $clone->array[$reference] = $object->getInstance();
        }
        return $clone;
    }