You are here

private function ChainDecoder::getDecoder in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Encoder/ChainDecoder.php \Symfony\Component\Serializer\Encoder\ChainDecoder::getDecoder()

Gets the decoder supporting the format.

Parameters

string $format:

Return value

DecoderInterface

Throws

RuntimeException if no decoder is found

1 call to ChainDecoder::getDecoder()
ChainDecoder::supportsDecoding in vendor/symfony/serializer/Encoder/ChainDecoder.php
Checks whether the deserializer can decode from given format.

File

vendor/symfony/serializer/Encoder/ChainDecoder.php, line 64

Class

ChainDecoder
Decoder delegating the decoding to a chain of decoders.

Namespace

Symfony\Component\Serializer\Encoder

Code

private function getDecoder($format) {
  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)) {
      $this->decoderByFormat[$format] = $i;
      return $decoder;
    }
  }
  throw new RuntimeException(sprintf('No decoder found for format "%s".', $format));
}