Example #1
0
 /**
  * @param string $string A string with format curie:id#tag
  * @return self
  */
 public static function fromString($string)
 {
     $parts = explode('#', $string, 2);
     $ref = $parts[0];
     $tag = isset($parts[1]) ? $parts[1] : null;
     $parts = explode(':', $ref, 5);
     $id = array_pop($parts);
     $curie = SchemaCurie::fromString(implode(':', $parts));
     return new self($curie, $id, $tag);
 }
Example #2
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);
 }
Example #3
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']);
 }