/** * Creates a new instance which will no longer contain the given object. * * @param FixtureInterface|ObjectInterface $objectOrFixture * * @return self */ public function without($objectOrFixture) : self { $clone = clone $this; unset($clone->objects[$objectOrFixture->getId()]); unset($clone->array[$objectOrFixture->getId()]); return $clone; }
/** * @param FixtureInterface $scope * @param FlagBag $flags * @param mixed|ValueInterface $value * * @throws InvalidScopeException * * @return ValueInterface */ private function generateValue(FixtureInterface $scope, FlagBag $flags, $value) : ValueInterface { $uniqueId = sprintf('%s#%s', $scope->getClassName(), $flags->getKey()); if ('temporary_id' === substr($scope->getId(), 0, 12)) { throw DenormalizerExceptionFactory::createForInvalidScopeForUniqueValue(); } if ($value instanceof DynamicArrayValue) { $uniqueId = uniqid($uniqueId . '::', true); return new DynamicArrayValue($value->getQuantifier(), new UniqueValue($uniqueId, $value->getElement())); } if ($value instanceof ArrayValue) { $uniqueId = uniqid($uniqueId . '::', true); $elements = $value->getValue(); foreach ($elements as $key => $element) { // The key must be the same for each argument: the unique ID is bound to the array, not the argument // number. $elements[$key] = new UniqueValue($uniqueId, $element); } return new ArrayValue($elements); } return new UniqueValue($uniqueId, $value); }
public static function createForFixture(FixtureInterface $fixture, FixturePropertyValue $value, int $code = 0, \Throwable $previous = null) : NoSuchPropertyException { return new NoSuchPropertyException(sprintf('Could not find the property "%s" of the object "%s" (class: %s).', $value->getProperty(), $fixture->getId(), $fixture->getClassName()), $code, $previous); }
public static function createForInstantiatorNotFoundForFixture(FixtureInterface $fixture) : InstantiatorNotFoundException { return new InstantiatorNotFoundException(sprintf('No suitable instantiator found for the fixture "%s".', $fixture->getId())); }
/** * @inheritdoc */ public function getId() : string { return $this->fixture->getId(); }
/** * Creates a new instance which will not contain the fixture of the given ID. Will still proceed even if such * fixture does not exist. * * @param FixtureInterface $fixture * * @return self */ public function without(FixtureInterface $fixture) : self { $clone = clone $this; unset($clone->fixtures[$fixture->getId()]); return $clone; }
/** * {@inheritdoc} * * @param ValueForCurrentValue $value * * @throws NoValueForCurrentException */ public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context) : ResolvedValueWithFixtureSet { return new ResolvedValueWithFixtureSet($fixtureSet->getFixtures()->get($fixture->getId()), $fixtureSet); }
public static function create(FixtureInterface $fixture) : NoValueForCurrentException { return new NoValueForCurrentException(sprintf('No value for \'<current()>\' found for the fixture "%s".', $fixture->getId())); }
public static function createForInvalidDynamicArrayQuantifier(FixtureInterface $fixture, int $quantifier) : \InvalidArgumentException { return new \InvalidArgumentException(sprintf('Expected quantifier to be a positive integer. Got "%d" for "%s", check you dynamic arrays ' . 'declarations (e.g. "<numberBetween(1, 2)>x @user*").', $quantifier, $fixture->getId())); }