Nelmio\Alice\Generator\ResolvedFixtureSet::withObjects PHP Method

withObjects() public method

public withObjects ( ObjectBag $objects ) : self
$objects Nelmio\Alice\ObjectBag
return self
    public function withObjects(ObjectBag $objects) : self
    {
        $clone = clone $this;
        $clone->objects = $objects;
        return $clone;
    }

Usage Example

 /**
  * {@inheritdoc}
  *
  * @throws InstantiationException
  */
 public function instantiate(FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, GenerationContext $context) : ResolvedFixtureSet
 {
     try {
         $instance = $this->createInstance($fixture);
     } catch (InstantiationThrowable $throwable) {
         throw $throwable;
     } catch (\Throwable $throwable) {
         throw InstantiationExceptionFactory::create($fixture, 0, $throwable);
     }
     $objects = $fixtureSet->getObjects()->with(new SimpleObject($fixture->getId(), $instance));
     return $fixtureSet->withObjects($objects);
 }