Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public final function serialize($data, $format, array $context = array())
 {
     if (!$this->supportsEncoding($format)) {
         throw new UnexpectedValueException(sprintf('Serialization for the format %s is not supported', $format));
     }
     if ($this->encoder->needsNormalization($format)) {
         $data = $this->normalize($data, $format, $context);
     }
     return $this->encode($data, $format, $context);
 }
Beispiel #2
0
 public function testNeedsNormalizationNormalizationAware()
 {
     $encoder = new NormalizationAwareEncoder();
     $sut = new ChainEncoder(array($encoder));
     $this->assertFalse($sut->needsNormalization(self::FORMAT_1));
 }