/**
* {@inheritdoc}
*
* @param FixtureMatchReferenceValue $value
*
* @throws UnresolvableValueException
*/
public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context) : ResolvedValueWithFixtureSet
{
if (null === $this->resolver) {
throw ResolverNotFoundExceptionFactory::createUnexpectedCall(__METHOD__);
}
$possibleIds = $this->getSuitableIds($value, $fixtureSet);
$id = Base::randomElement($possibleIds);
if (null === $id) {
throw UnresolvableValueExceptionFactory::createForNoFixtureOrObjectMatchingThePattern($value);
}
return $this->resolver->resolve(new FixtureReferenceValue($id), $fixture, $fixtureSet, $scope, $context);
}