create() public static method

public static create ( Nelmio\Alice\Definition\ValueInterface $value, integer $code, Throwable $previous = null ) : UnresolvableValueException
$value Nelmio\Alice\Definition\ValueInterface
$code integer
$previous Throwable
return UnresolvableValueException
Esempio n. 1
0
 /**
  * {@inheritdoc}
  *
  * @param FixtureReferenceValue $value
  *
  * @throws UnresolvableValueException
  */
 public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context) : ResolvedValueWithFixtureSet
 {
     if (null === $this->generator) {
         throw ObjectGeneratorNotFoundExceptionFactory::createUnexpectedCall(__METHOD__);
     }
     $referredFixtureId = $value->getValue();
     if ($referredFixtureId instanceof ValueInterface) {
         throw UnresolvableValueExceptionFactory::create($value);
     }
     $referredFixture = $this->getReferredFixture($referredFixtureId, $fixtureSet);
     return $this->resolveReferredFixture($referredFixture, $referredFixtureId, $fixtureSet, $context);
 }
 /**
  * {@inheritdoc}
  *
  * @param FixturePropertyValue $value
  *
  * @throws NoSuchPropertyException
  * @throws UnresolvableValueException
  */
 public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context) : ResolvedValueWithFixtureSet
 {
     if (null === $this->resolver) {
         throw ResolverNotFoundExceptionFactory::createUnexpectedCall(__METHOD__);
     }
     $context->markAsNeedsCompleteGeneration();
     $fixtureReferenceResult = $this->resolver->resolve($value->getReference(), $fixture, $fixtureSet, $scope, $context);
     $context->unmarkAsNeedsCompleteGeneration();
     /** @var ResolvedFixtureSet $fixtureSet */
     list($instance, $fixtureSet) = [$fixtureReferenceResult->getValue(), $fixtureReferenceResult->getSet()];
     try {
         $propertyValue = $this->propertyAccessor->getValue($instance, $value->getProperty());
     } catch (SymfonyNoSuchPropertyException $exception) {
         throw NoSuchPropertyExceptionFactory::createForFixture($fixture, $value, 0, $exception);
     } catch (\Exception $exception) {
         throw UnresolvableValueExceptionFactory::create($value, 0, $exception);
     }
     return new ResolvedValueWithFixtureSet($propertyValue, $fixtureSet);
 }