本文整理汇总了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;
}