Procházet zdrojové kódy

use getEncoder inside encode/decode

Lukas Kahwe Smith před 14 roky
rodič
revize
5b3ccba2a1
1 změnil soubory, kde provedl 2 přidání a 10 odebrání
  1. 2 10
      src/Symfony/Component/Serializer/Serializer.php

+ 2 - 10
src/Symfony/Component/Serializer/Serializer.php

@@ -121,11 +121,7 @@ class Serializer implements SerializerInterface
      */
     public final function encode($data, $format)
     {
-        if (!isset($this->encoders[$format])) {
-            throw new \UnexpectedValueException('No encoder registered for the '.$format.' format');
-        }
-
-        return $this->encoders[$format]->encode($data, $format);
+        return $this->getEncoder($format)->encode($data, $format);
     }
 
     /**
@@ -133,11 +129,7 @@ class Serializer implements SerializerInterface
      */
     public final function decode($data, $format)
     {
-        if (!isset($this->encoders[$format])) {
-            throw new \UnexpectedValueException('No decoder registered for the '.$format.' format');
-        }
-
-        return $this->encoders[$format]->decode($data, $format);
+        return $this->getEncoder($format)->decode($data, $format);
     }
 
     /**