Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\FixtureDenormalizerRegistry::denormalize PHP Метод

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

public denormalize ( FixtureBag $builtFixtures, string $className, string $fixtureId, array $specs, FlagBag $flags ) : FixtureBag
$builtFixtures Nelmio\Alice\FixtureBag
$className string
$fixtureId string
$specs array
$flags Nelmio\Alice\Definition\FlagBag
Результат Nelmio\Alice\FixtureBag
    public function denormalize(FixtureBag $builtFixtures, string $className, string $fixtureId, array $specs, FlagBag $flags) : FixtureBag
    {
        foreach ($this->denormalizers as $denormalizer) {
            if ($denormalizer->canDenormalize($fixtureId)) {
                return $denormalizer->denormalize($builtFixtures, $className, $fixtureId, $specs, $flags);
            }
        }
        throw DenormalizerExceptionFactory::createDenormalizerNotFoundForFixture($fixtureId);
    }

Usage Example

 /**
  * @expectedException \Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\DenormalizerNotFoundException
  * @expectedExceptionMessage No suitable fixture denormalizer found to handle the fixture with the reference "user0".
  */
 public function testThrowsExceptionIfNotSuitableDenormalizer()
 {
     $builtFixtures = new FixtureBag();
     $className = 'Nelmio\\Alice\\Entity\\User';
     $reference = 'user0';
     $specs = ['username' => '<name()>'];
     $flags = new FlagBag('');
     $flagParserProphecy = $this->prophesize(FlagParserInterface::class);
     $flagParserProphecy->parse(Argument::any())->shouldNotBeCalled();
     /** @var FlagParserInterface $flagParser */
     $flagParser = $flagParserProphecy->reveal();
     $denormalizer = new FixtureDenormalizerRegistry($flagParser, []);
     $denormalizer->denormalize($builtFixtures, $className, $reference, $specs, $flags);
 }
FixtureDenormalizerRegistry