Nelmio\Alice\Generator\Resolver\Value\Chainable\ParameterValueResolver::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
    {
        $parameterKey = $value->getValue();
        $parameters = $fixtureSet->getParameters();
        if (false === $parameters->has($parameterKey)) {
            throw UnresolvableValueExceptionFactory::createForCouldNotFindParameter($parameterKey);
        }
        return new ResolvedValueWithFixtureSet($parameters->get($parameterKey), $fixtureSet);
    }

Usage Example

 /**
  * @expectedException \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException
  * @expectedExceptionMessage Could not find the parameter "foo".
  */
 public function testThrowsAnExceptionIfTheVariableCannotBeFoundInTheScope()
 {
     $value = new ParameterValue('foo');
     $set = ResolvedFixtureSetFactory::create();
     $resolver = new ParameterValueResolver();
     $resolver->resolve($value, new FakeFixture(), $set, [], new GenerationContext());
 }
ParameterValueResolver