ApiPlatform\Core\Hydra\Serializer\EntrypointNormalizer::supportsNormalization PHP Method

supportsNormalization() public method

public supportsNormalization ( $data, $format = null, array $context = [] )
$context array
    public function supportsNormalization($data, $format = null, array $context = [])
    {
        return self::FORMAT === $format && $data instanceof Entrypoint;
    }

Usage Example

 public function testSupportNormalization()
 {
     $collection = new ResourceNameCollection();
     $entrypoint = new Entrypoint($collection);
     $factoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
     $iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
     $urlGeneratorProphecy = $this->prophesize(UrlGeneratorInterface::class);
     $normalizer = new EntrypointNormalizer($factoryProphecy->reveal(), $iriConverterProphecy->reveal(), $urlGeneratorProphecy->reveal());
     $this->assertTrue($normalizer->supportsNormalization($entrypoint, EntrypointNormalizer::FORMAT));
     $this->assertFalse($normalizer->supportsNormalization($entrypoint, 'json'));
     $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), EntrypointNormalizer::FORMAT));
 }