Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueDuringGenerationExceptionFactory::createFromResolutionThrowable PHP Method

createFromResolutionThrowable() public static method

public static createFromResolutionThrowable ( Nelmio\Alice\Throwable\ResolutionThrowable $previous ) : UnresolvableValueDuringGenerationException
$previous Nelmio\Alice\Throwable\ResolutionThrowable
return UnresolvableValueDuringGenerationException
    public static function createFromResolutionThrowable(ResolutionThrowable $previous) : UnresolvableValueDuringGenerationException
    {
        return new UnresolvableValueDuringGenerationException('Could not resolve value during the generation process.', 0, $previous);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function hydrate(ObjectInterface $object, ResolvedFixtureSet $fixtureSet, GenerationContext $context) : ResolvedFixtureSet
 {
     if (null === $this->resolver) {
         throw ResolverNotFoundExceptionFactory::createUnexpectedCall(__METHOD__);
     }
     $fixture = $fixtureSet->getFixtures()->get($object->getId());
     $properties = $fixture->getSpecs()->getProperties();
     $scope = ['_instances' => $fixtureSet->getObjects()->toArray()];
     foreach ($properties as $property) {
         /** @var Property $property */
         $propertyValue = $property->getValue();
         if ($propertyValue instanceof ValueInterface) {
             try {
                 $result = $this->resolver->resolve($propertyValue, $fixture, $fixtureSet, $scope, $context);
             } catch (ResolutionThrowable $throwable) {
                 throw UnresolvableValueDuringGenerationExceptionFactory::createFromResolutionThrowable($throwable);
             }
             list($propertyValue, $fixtureSet) = [$result->getValue(), $result->getSet()];
             $property = $property->withValue($propertyValue);
         }
         $scope[$property->getName()] = $propertyValue;
         $object = $this->hydrator->hydrate($object, $property, $context);
     }
     return $fixtureSet->withObjects($fixtureSet->getObjects()->with($object));
 }
All Usage Examples Of Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueDuringGenerationExceptionFactory::createFromResolutionThrowable
UnresolvableValueDuringGenerationExceptionFactory