Просмотр исходного кода

use getEncoder inside encode/decode

Lukas Kahwe Smith 14 лет назад
Родитель
Сommit
5b3ccba2a1
1 измененных файлов с 2 добавлено и 10 удалено
  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);
     }
 
     /**