* * 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:----p+Ix44fRvfecfMHAMraji/23GtQZ4XJ/eeagedl7zr183Jl6eUuz0QqxKzfwzf/ZkS4u6kQcX1z2CRcOWtRrOiiRJN6CuAC6SxlXFoE/OG/0qar1Gyov+WINXpgVW8yNHDH6Z6Go0Dz/Dqmn35cCZA4l1Hi8O9oWoPPgYhZWgIN4wTTuta0SBXyQfTBKeZpmuPE+PgQK0GfBZorv8DmC176bXpmRIdMD8pY7HSVJe4489JIo1CpDquRcnqbTLqcYLG6Lak0WpyEHi4KfjH+x0jTgo2vlCLMl2exVSVcCRrefa4YMUq8sCq5AtLsivIWS3vvQws6TSYEqDMiUFzlaX9/hkLi01/LxqlLM3bAQKEIt6RwDQZVnbi9+FQtsw+Vx2JTHIJJNT2YBbGUWOjVd3PUpvVrhOpuA9dbk0jFcMveLuGkxKCN7oRcEOop03U90hdfTO8YuScb5YYDI+Kqjp2gjULC3o2FVJlekn29Gt5HMMcCtRDXYKMZQfHxaVgEWKroaUI8qZtJuXpFPZEiNe6xj9f1+s1OasStcux5UXaxDZomCvE0HusT/nSzfaga0hxCtxJEUWQQQ1yOdx4PTu0YS3FiwCFLUeQY83p1f3L+6OUsxWAtam0vmLlx++HrpW8y42RoEXY96ca9Mji8BNjgJSTymFd9pMzFSWYeXCJI=----ATTACHMENT:----NDg4MTQyOTk4NjYwMTA3OSA3NjE5Njk1MzQ2MzUxMzYyIDU1NDg1NzgyNDE1NjIzODY=