Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Constructor\ConstructorWithCallerDenormalizer::denormalize PHP Method

denormalize() public method

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
return Nelmio\Alice\Definition\MethodCallInterface
    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());
    }

Usage Example

 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Invalid constructor method "@foo::bar::baz".
  */
 public function testThrowsExceptionIfInvalidConstructor()
 {
     $constructor = ['@foo::bar::baz' => $arguments = ['<latitude()>', '1 (unique)' => '<longitude()>']];
     $fixture = new FakeFixture();
     $flagParser = new FakeFlagParser();
     $argumentsDenormalizer = new FakeArgumentsDenormalizer();
     $denormalizer = new ConstructorWithCallerDenormalizer(new SimpleConstructorDenormalizer($argumentsDenormalizer));
     $denormalizer->denormalize($fixture, $flagParser, $constructor);
 }
ConstructorWithCallerDenormalizer