本文整理匯總了PHP中EasyRdf_Namespace::splitUri方法的典型用法代碼示例。如果您正苦於以下問題:PHP EasyRdf_Namespace::splitUri方法的具體用法?PHP EasyRdf_Namespace::splitUri怎麽用?PHP EasyRdf_Namespace::splitUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類EasyRdf_Namespace
的用法示例。
在下文中一共展示了EasyRdf_Namespace::splitUri方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSplitUriNonString
public function testSplitUriNonString()
{
$this->setExpectedException('InvalidArgumentException', '$uri should be a string or EasyRdf_Resource');
EasyRdf_Namespace::splitUri($this);
}
示例2: resourceToSparql
/**
* Return a SPARQL representation of another resource
* We have to do this because other resource does not always extend the EasySpinRdf_Resource element
* @param $resource
* @param $concat
* @return string
* @todo Change the EasyRdf type mapper to define a default resource class and use a default getSparql method
*/
public function resourceToSparql($resource, $concat = " ")
{
// if the resource is a collection, we concat sparql with the $concat param
if (is_a($resource, 'EasyRdf_Collection')) {
$resources = array();
foreach ($resource as $item) {
$resources[] = $this->resourceToSparql($item);
}
return join($concat, $resources);
}
// if the resource implement getSparql method, just use it
if (method_exists($resource, 'getSparql')) {
return $resource->getSparql();
}
// if the resource is a literal return its value
if (is_a($resource, 'EasyRdf_Literal')) {
$value = $resource->getValue();
return is_int($value) ? $value : '"' . $value . '"';
}
// if the resource has a sp:varName property, use it as a variable
if ($varName = $resource->get('sp:varName')) {
return "?" . $varName->getValue();
}
// if the resource is a bnode, lets adapt it to SPIN specifications
if ($resource->isBNode()) {
return '?' . substr($resource->getUri(), 2);
}
list($prefix, $suffix) = \EasyRdf_Namespace::splitUri($resource);
if (in_array($prefix, array('sp', 'spin')) && $suffix[0] == "_") {
$resource = '?' . substr($suffix, 1);
} elseif (\EasyRdf_Namespace::shorten($resource)) {
$resource = \EasyRdf_Namespace::shorten($resource);
} else {
$resource = "<" . $resource . ">";
}
return $resource;
}