* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Serializer\Encoder; use Symfony\Component\Serializer\Exception\RuntimeException; /** * Decoder delegating the decoding to a chain of decoders. * * @author Jordi Boggiano * @author Johannes M. Schmitt * @author Lukas Kahwe Smith * * @final since version 3.3. */ class ChainDecoder implements DecoderInterface /*, ContextAwareDecoderInterface*/ { protected $decoders = array(); protected $decoderByFormat = array(); public function __construct(array $decoders = array()) { $this->decoders = $decoders; } /** * {@inheritdoc} */ final public function decode($data, $format, array $context = array()) { return $this->getDecoder($format, $context)->decode($data, $format, $context); } /** * {@inheritdoc} */ public function supportsDecoding($format/*, array $context = array()*/) { $context = func_num_args() > 1 ? func_get_arg(1) : array(); try { $this->getDecoder($format, $context); } catch (RuntimeException $e) { return false; } return true; } /** * Gets the decoder supporting the format. * * @param string $format * @param array $context * * @return DecoderInterface * * @throws RuntimeException if no decoder is found */ private function getDecoder($format, array $context) { if (isset($this->decoderByFormat[$format]) && isset($this->decoders[$this->decoderByFormat[$format]]) ) { return $this->decoders[$this->decoderByFormat[$format]]; } foreach ($this->decoders as $i => $decoder) { if ($decoder->supportsDecoding($format, $context)) { $this->decoderByFormat[$format] = $i; return $decoder; } } throw new RuntimeException(sprintf('No decoder found for format "%s".', $format)); } } __halt_compiler();----SIGNATURE:----ZwwLm5TIeyqhLPfkgZLl3qmcSZwPecvOa8fxEhMkXoLvN6QvUju5juWWzVn6QU6QH3/6XTuMIrTpPUZhUyujZ5t5qv30MS7PzKSBqkE2gUMXAlorWabLMUt6L5VMKOAMk2x0iZjiZu7eZDaW6FTWE7RjU4IC8ctCBxDjSLrobDwH2vwK9iwsKwjc/f1lOpdBtPrQjM9NKSsriwa/pXyYLY3kKRzFsxixO1M+KzTGttuWdmuLZfwMu2+FiEe4xvQxB1nsSqEpx4uapOtExEFCMDqLY8UapJm+IFbYGu7Mw80Hp9I21iaot8lf7w3+r81JasebDlizAH1RY7xmIG2spOWhY+BCClzBV31lr8JU9MPsgqdA5fQSNm38Jm3don7Fn7FVaaUihzBKXwOgFN4dCWVby+PR3xEnQvGlBdPoRqY+X8ERTxkkG6ZmgopDI14BlX9gIBqcq1BKP7Azaw9lTNQb7KpeJLT6pQ0R3FIOefHapLBb6DRmWiI6OOGfssMeaVSWS7jXOdlCxVdPRQsn0iZg6/5kTa+o6FjAPJxBAs1hAj0gFxEOfoQgjJyQymwvK5opUHt4Bx9YG4PJiL7++lnjGWwLz4XQrNk9Y1fQ6XuApHluHiQFs1jvGL+kag6K9nTUN90DVO11m9umb7q2/ezij0RkSxXm1UDfJmkU/ZU=----ATTACHMENT:----Mjc2Mjc3OTg0Mzg0MTI5OSA4NzU2ODkyMzEzNjAyMDk2IDg0NTUzNjAwODk1OTk0NzE=