You are here

public static function EasyRdf_Namespace::expand in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Namespace.php \EasyRdf_Namespace::expand()

Expand a shortened URI (qname) back into a full URI.

If it isn't possible to expand the qname, for example if the namespace isn't registered, then the original string will be returned.

Parameters

string $shortUri The short URI (eg 'foaf:name'):

Return value

string The full URI (eg 'http://xmlns.com/foaf/0.1/name')

12 calls to EasyRdf_Namespace::expand()
EasyRdf_Graph::addType in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add one or more rdf:type properties to a resource
EasyRdf_Graph::checkResourceParam in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Check that a URI/resource parameter is valid, and convert it to a string @ignore
EasyRdf_Graph::checkSinglePropertyParam in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Check that a single URI/property parameter (not a property path) is valid, and expand it if required @ignore
EasyRdf_Graph::isA in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Check if a resource is of the specified type
EasyRdf_Literal::create in vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php
Create a new literal object

... See full list

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Namespace.php, line 394

Class

EasyRdf_Namespace
A namespace registry and manipulation class.

Code

public static function expand($shortUri) {
  if (!is_string($shortUri) or $shortUri === '') {
    throw new InvalidArgumentException("\$shortUri should be a string and cannot be null or empty");
  }
  if ($shortUri === 'a') {
    $namespaces = self::namespaces();
    return $namespaces['rdf'] . 'type';
  }
  elseif (preg_match('/^(\\w+?):([\\w\\-]+)$/', $shortUri, $matches)) {
    $long = self::get($matches[1]);
    if ($long) {
      return $long . $matches[2];
    }
  }
  elseif (preg_match('/^(\\w+)$/', $shortUri) and isset(self::$default)) {
    return self::$default . $shortUri;
  }
  return $shortUri;
}