You are here

public static function EasyRdf_Namespace::setDefault in Zircon Profile 8

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

Set the default namespace

Set the default namespace to either a URI or the prefix of an already defined namespace.

Example: EasyRdf_Namespace::setDefault('http://schema.org/');

Parameters

string $namespace The URI or prefix of a namespace (eg 'og'):

File

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

Class

EasyRdf_Namespace
A namespace registry and manipulation class.

Code

public static function setDefault($namespace) {
  if (is_null($namespace) or $namespace === '') {
    self::$default = null;
  }
  elseif (preg_match('/^\\w+$/', $namespace)) {
    $namespaces = self::namespaces();
    if (!isset($namespaces[$namespace])) {
      throw new InvalidArgumentException("Unable to set default namespace to unknown prefix: {$namespace}");
    }
    self::$default = $namespaces[$namespace];
  }
  else {
    self::$default = $namespace;
  }
}