-
Notifications
You must be signed in to change notification settings - Fork 10
/
QueryString.php
37 lines (32 loc) · 1015 Bytes
/
QueryString.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace QueryTranslator\Languages\Galach\Generators;
use QueryTranslator\Languages\Galach\Generators\Common\Visitor;
use QueryTranslator\Values\SyntaxTree;
/**
* QueryString generator generates query string in Elasticsearch Query String Query format.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
*/
final class QueryString
{
/**
* @var \QueryTranslator\Languages\Galach\Generators\Common\Visitor
*/
private $visitor;
public function __construct(Visitor $visitor)
{
$this->visitor = $visitor;
}
/**
* Generate query string in Elasticsearch Query String Query format from the given $syntaxTree.
*
* @param \QueryTranslator\Values\SyntaxTree $syntaxTree
* @param mixed $options
*
* @return string
*/
public function generate(SyntaxTree $syntaxTree, $options = null)
{
return $this->visitor->visit($syntaxTree->rootNode, null, $options);
}
}