/** * @param string $uri URI of the new named node. * @return NamedNode */ public function createNamedNode($uri) { if ($uri === null) { throw new \Exception('Can\'t initialize node with null.'); } if (!NodeUtils::simpleCheckURI($uri)) { throw new \Exception('Invalid URI was given for RDF NamedNode creation.'); } // TODO catch invalid URIs $world = librdf_php_get_world(); $uri = librdf_new_uri($world, $uri); $redlandNode = librdf_new_node_from_uri($world, $uri); if ($redlandNode === null) { throw new \Exception('Initialization of redland node failed.'); } return new NamedNode($redlandNode); }
/** * Create a new URINode from a URI object. * * @param mixed $uri The URI string or librdf_node value to use * @return void * @throws LibRDF_Error If unable to create a new URI * @access public */ public function __construct($uri) { if (is_string($uri)) { $uri = new LibRDF_URI($uri); $this->node = librdf_new_node_from_uri(librdf_php_get_world(), $uri->getURI()); } elseif (is_resource($uri) and librdf_node_is_resource($uri)) { $this->node = $uri; } else { throw new LibRDF_Error("Argument is not a string or \n librdf_node resource"); } if (!$this->node) { throw new LibRDF_Error("Unable to create new URI node"); } }