Пример #1
0
 /**
  * @param SchemaCurie $curie
  * @return SchemaQName
  */
 public static function fromCurie(SchemaCurie $curie)
 {
     $qname = sprintf('%s:%s', $curie->getVendor(), $curie->getMessage());
     if (isset(self::$instances[$qname])) {
         return self::$instances[$qname];
     }
     self::$instances[$qname] = new self($curie->getVendor(), $curie->getMessage());
     return self::$instances[$qname];
 }
Пример #2
0
 /**
  * @return string
  */
 public function toString()
 {
     if (null !== $this->tag) {
         return $this->curie->toString() . ':' . $this->id . '#' . $this->tag;
     }
     return $this->curie->toString() . ':' . $this->id;
 }
Пример #3
0
 /**
  * Returns the SchemaCurie for the given SchemaQName.
  *
  * @param SchemaQName $qname
  * @return SchemaCurie
  *
  * @throws NoMessageForQName
  */
 public static function resolveQName(SchemaQName $qname)
 {
     $key = $qname->toString();
     if (isset(self::$resolvedQnames[$key])) {
         return self::$resolvedQnames[$key];
     }
     $qvendor = $qname->getVendor();
     $qmessage = $qname->getMessage();
     foreach (self::$messages as $id => $class) {
         list($vendor, $package, $category, $message) = explode(':', $id);
         if ($qvendor === $vendor && $qmessage === $message) {
             return self::$resolvedQnames[$key] = SchemaCurie::fromString($vendor . ':' . $package . ':' . $category . ':' . $message);
         }
     }
     throw new NoMessageForQName($qname);
 }
Пример #4
0
 /**
  * @param mixed $value
  * @param Field $field
  *
  * @return MessageRef
  */
 public function decodeMessageRef($value, Field $field)
 {
     return new MessageRef(SchemaCurie::fromString($value['curie']['S']), $value['id']['S'], isset($value['tag']['NULL']) ? null : $value['tag']['S']);
 }
Пример #5
0
 /**
  * @return SchemaQName
  */
 public function getQName()
 {
     return $this->curie->getQName();
 }
Пример #6
0
 /**
  * @param SchemaCurie $curie
  */
 public function __construct(SchemaCurie $curie)
 {
     $this->curie = $curie;
     parent::__construct(sprintf('MessageResolver is unable to resolve [%s] to a class name.', $curie->toString()));
 }