Example #1
0
 public function decode(\DOMNode $node, Type $type)
 {
     if (isset($this->fromMap[$type->getNs()][$type->getName()])) {
         $decoder = $this->fromMap[$type->getNs()][$type->getName()];
         if ($decoder instanceof DecoderInterface) {
             return $decoder->decode($node, $type);
         } else {
             return call_user_func($decoder, $node, $type, $this);
         }
     }
     if (isset($this->fromFallback[$type->getNs()])) {
         $decoder = $this->fromFallback[$type->getNs()];
         if ($decoder instanceof DecoderInterface) {
             return $decoder->decode($node, $type);
         } else {
             return call_user_func($decoder, $node, $type, $this);
         }
     }
     foreach ($this->fromFallbackLast as $decoder) {
         if ($decoder->supports($type)) {
             return $decoder->decode($node, $type);
         }
     }
     throw new ConversionNotFoundException("Can't find a valid decoder for " . $type);
 }
 public function supports(Type $type)
 {
     return isset($this->fromMap[$type->getNs()][$type->getName()]);
 }