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

supportsNormalization() public method

public supportsNormalization ( $data, $format = null )
    public function supportsNormalization($data, $format = null)
    {
        return self::FORMAT === $format && $data instanceof ConstraintViolationListInterface;
    }

Usage Example

 public function testSupportNormalization()
 {
     $urlGeneratorProphecy = $this->prophesize(UrlGeneratorInterface::class);
     $normalizer = new ConstraintViolationListNormalizer($urlGeneratorProphecy->reveal());
     $this->assertTrue($normalizer->supportsNormalization(new ConstraintViolationList(), ConstraintViolationListNormalizer::FORMAT));
     $this->assertFalse($normalizer->supportsNormalization(new ConstraintViolationList(), 'xml'));
     $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), ConstraintViolationListNormalizer::FORMAT));
 }
ConstraintViolationListNormalizer