You are here

protected function EasyRdf_Graph::checkResourceParam in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php \EasyRdf_Graph::checkResourceParam()

Check that a URI/resource parameter is valid, and convert it to a string @ignore

28 calls to EasyRdf_Graph::checkResourceParam()
EasyRdf_Graph::add in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add data to the graph
EasyRdf_Graph::addLiteral in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add a literal value as a property of a resource
EasyRdf_Graph::addResource in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add a resource as a property of another resource
EasyRdf_Graph::addType in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add one or more rdf:type properties to a resource
EasyRdf_Graph::all in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get all values for a property path

... See full list

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php, line 425

Class

EasyRdf_Graph
Container for collection of EasyRdf_Resources.

Code

protected function checkResourceParam(&$resource, $allowNull = false) {
  if ($allowNull == true) {
    if ($resource === null) {
      if ($this->uri) {
        $resource = $this->uri;
      }
      else {
        return;
      }
    }
  }
  elseif ($resource === null) {
    throw new InvalidArgumentException("\$resource should be either IRI, blank-node identifier or EasyRdf_Resource. got null");
  }
  if (is_object($resource) and $resource instanceof EasyRdf_Resource) {
    $resource = $resource
      ->getUri();
  }
  elseif (is_object($resource) and $resource instanceof EasyRdf_ParsedUri) {
    $resource = strval($resource);
  }
  elseif (is_string($resource)) {
    if ($resource == '') {
      throw new InvalidArgumentException("\$resource should be either IRI, blank-node identifier or EasyRdf_Resource. got empty string");
    }
    elseif (preg_match("|^<(.+)>\$|", $resource, $matches)) {
      $resource = $matches[1];
    }
    else {
      $resource = EasyRdf_Namespace::expand($resource);
    }
  }
  else {
    throw new InvalidArgumentException("\$resource should be either IRI, blank-node identifier or EasyRdf_Resource");
  }
}