Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueExceptionFactory::createForCouldNotFindVariable PHP Méthode

createForCouldNotFindVariable() public static méthode

public static createForCouldNotFindVariable ( Nelmio\Alice\Definition\ValueInterface $value, integer $code, Throwable $previous = null ) : UnresolvableValueException
$value Nelmio\Alice\Definition\ValueInterface
$code integer
$previous Throwable
Résultat UnresolvableValueException
    public static function createForCouldNotFindVariable(ValueInterface $value, int $code = 0, \Throwable $previous = null) : UnresolvableValueException
    {
        return new UnresolvableValueException(sprintf('Could not find a variable "%s".', $value->getValue()), $code, $previous);
    }

Usage Example

 /**
  * {@inheritdoc}
  *
  * @param VariableValue $value
  *
  * @throws UnresolvableValueException
  */
 public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context) : ResolvedValueWithFixtureSet
 {
     $variableName = $value->getValue();
     if (array_key_exists($variableName, $scope)) {
         return new ResolvedValueWithFixtureSet($scope[$variableName], $fixtureSet);
     }
     throw UnresolvableValueExceptionFactory::createForCouldNotFindVariable($value);
 }