Пример #1
0
 /**
  * Returns the plain SPARQL string of this query.
  *
  * @param bool $includePrefixes
  * @return string
  * @throws InvalidArgumentException
  * @throws RangeException
  */
 public function getSPARQL($includePrefixes = true)
 {
     if (!is_bool($includePrefixes)) {
         throw new InvalidArgumentException('$includePrefixes has to be a bool');
     }
     $this->usageValidator->validate();
     $sparql = $includePrefixes ? $this->prefixBuilder->getSPARQL() : '';
     $sparql .= 'SELECT ' . $this->uniqueness . $this->formatSelects() . ' WHERE';
     $sparql .= ' {' . $this->graphBuilder->getSPARQL() . ' }';
     $sparql .= $this->modifierBuilder->getSPARQL();
     return $sparql;
 }
Пример #2
0
 private function getGraphBuilder($subject, $predicate, $object)
 {
     if ($subject instanceof GraphBuilder) {
         return $subject;
     }
     $graphBuilder = new GraphBuilder($this->usageValidator);
     return $graphBuilder->where($subject, $predicate, $object);
 }
Пример #3
0
 public function testGetSPARQL()
 {
     $graphBuilder = new GraphBuilder(new UsageValidator());
     $graphBuilder->where('?a', '?b', '?c');
     $graphBuilder->also('?x', '?y');
     $graphBuilder->also('?z');
     $graphBuilder->where('?a', '?b', '?z');
     $this->assertEquals(' ?a ?b ?c , ?z ; ?x ?y , ?z .', $graphBuilder->getSPARQL());
 }