Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Constructor\SimpleConstructorDenormalizer::denormalize PHP Метод

denormalize() публичный Метод

public denormalize ( Nelmio\Alice\FixtureInterface $scope, Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParserInterface $parser, array $unparsedConstructor ) : Nelmio\Alice\Definition\MethodCallInterface
$scope Nelmio\Alice\FixtureInterface
$parser Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParserInterface
$unparsedConstructor array
Результат Nelmio\Alice\Definition\MethodCallInterface
    public function denormalize(FixtureInterface $scope, FlagParserInterface $parser, array $unparsedConstructor) : MethodCallInterface
    {
        /** @var int|string|null $firstKey */
        $firstKey = key($unparsedConstructor);
        if (null === $firstKey || is_int($firstKey) || count($unparsedConstructor) > 1 || is_string($firstKey) && preg_match('/\\(.*\\)/', $firstKey)) {
            return new SimpleMethodCall('__construct', $this->argumentDenormalizer->denormalize($scope, $parser, $unparsedConstructor));
        }
        throw DenormalizerExceptionFactory::createForUndenormalizableConstructor();
    }

Usage Example

 /**
  * @inheritdoc
  */
 public function denormalize(FixtureInterface $scope, FlagParserInterface $parser, array $unparsedConstructor) : MethodCallInterface
 {
     try {
         return $this->simpleConstructorDenormalizer->denormalize($scope, $parser, $unparsedConstructor);
     } catch (UnexpectedValueException $exception) {
         // Continue
     }
     /** @var string $firstKey */
     $firstKey = key($unparsedConstructor);
     list($caller, $method) = $this->getCallerReference($scope, $firstKey);
     $arguments = $this->simpleConstructorDenormalizer->denormalize($scope, $parser, $unparsedConstructor[$firstKey]);
     return new MethodCallWithReference($caller, $method, $arguments->getArguments());
 }
SimpleConstructorDenormalizer