Nelmio\Alice\Generator\Resolver\Value\ValueResolverRegistry::resolve PHP Method

resolve() public method

public resolve ( Nelmio\Alice\Definition\ValueInterface $value, Nelmio\Alice\FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context ) : ResolvedValueWithFixtureSet
$value Nelmio\Alice\Definition\ValueInterface
$fixture Nelmio\Alice\FixtureInterface
$fixtureSet Nelmio\Alice\Generator\ResolvedFixtureSet
$scope array
$context Nelmio\Alice\Generator\GenerationContext
return Nelmio\Alice\Generator\ResolvedValueWithFixtureSet
    public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context) : ResolvedValueWithFixtureSet
    {
        foreach ($this->resolvers as $resolver) {
            if ($resolver->canResolve($value)) {
                return $resolver->resolve($value, $fixture, $fixtureSet, $scope, $context);
            }
        }
        throw ResolverNotFoundExceptionFactory::createForValue($value);
    }

Usage Example

 /**
  * @expectedException \Nelmio\Alice\Throwable\Exception\Generator\Resolver\ResolverNotFoundException
  * @expectedExceptionMessage No resolver found to resolve value "foo".
  */
 public function testThrowExceptionIfNoSuitableParserIsFound()
 {
     $fixture = new DummyFixture('dummy');
     $set = ResolvedFixtureSetFactory::create();
     $registry = new ValueResolverRegistry([]);
     $registry->resolve(new DummyValue('foo'), $fixture, $set, [], new GenerationContext());
 }