/**
* Creates a new instance which will contain the given object. If an object with the same reference already exists,
* it will be overridden by the new object.
*
* @param ObjectInterface $object
*
* @return self
*/
public function with(ObjectInterface $object) : self
{
$clone = clone $this;
$clone->objects[$object->getId()] = $object;
$clone->array[$object->getId()] = $object->getInstance();
return $clone;
}