コード例 #1
0
ファイル: QueryBuilder.php プロジェクト: babarinde/asparagus
 /**
  * Specifies the expressions to select.
  *
  * @param string|string[] $expressions
  * @return self
  * @throws InvalidArgumentException
  */
 public function select($expressions)
 {
     $expressions = is_array($expressions) ? $expressions : func_get_args();
     foreach ($expressions as $expression) {
         $this->expressionValidator->validate($expression, ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS);
         // @todo temp hack to add AS definitions to defined variables
         $regexHelper = new RegexHelper();
         $matches = $regexHelper->getMatches('AS \\{variable}', $expression);
         $this->usageValidator->trackDefinedVariables($matches);
         // @todo detect functions and wrap with brackets automatically
         $this->usageValidator->trackUsedVariables($expression);
         $this->selects[] = $expression;
     }
     return $this;
 }
コード例 #2
0
ファイル: GraphBuilder.php プロジェクト: benestar/asparagus
 /**
  * Adds the given subquery.
  *
  * @param QueryBuilder $queryBuilder
  * @return self
  * @throws InvalidArgumentException
  */
 public function subquery(QueryBuilder $queryBuilder)
 {
     $this->subqueries[] = $queryBuilder->getSPARQL(false);
     $this->usageValidator->trackDefinedVariables(implode(' ', $queryBuilder->getSelects()));
     // @todo temp hack to add AS definitions to defined variables
     $regexHelper = new RegexHelper();
     $matches = $regexHelper->getMatches('AS \\{variable}', implode(' ', $queryBuilder->getSelects()));
     $this->usageValidator->trackDefinedVariables($matches);
     return $this;
 }
コード例 #3
0
ファイル: UsageValidator.php プロジェクト: benestar/asparagus
 private function matchPrefixes($expression)
 {
     return $this->regexHelper->getMatches('(^|\\W)(\\{prefix}):\\{name}', $expression, 2);
 }
コード例 #4
0
 /**
  * @dataProvider provideGetMatches
  */
 public function testGetMatches($regex, $expression, $matches)
 {
     $regexHelper = new RegexHelper();
     $this->assertEquals($matches, $regexHelper->getMatches($regex, $expression));
 }
コード例 #5
0
ファイル: QueryBuilder.php プロジェクト: benestar/asparagus
 private function addExpressions(array $expressions, $options = null)
 {
     foreach ($expressions as $expression) {
         $this->expressionValidator->validate($expression, $options ?: ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION_AS);
         // @todo temp hack to add AS definitions to defined variables
         $regexHelper = new RegexHelper();
         $matches = $regexHelper->getMatches('AS \\{variable}', $expression);
         $this->usageValidator->trackDefinedVariables($matches);
         // @todo detect functions and wrap with brackets automatically
         $this->usageValidator->trackUsedVariables($expression);
         $this->usageValidator->trackUsedPrefixes($expression);
         $this->selects[] = $expression;
     }
 }