GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f769c2...a53f28 )
by Anderson
05:19
created

QueryParser::parse()   D

Complexity

Conditions 9
Paths 40

Size

Total Lines 44
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 4.909
c 0
b 0
f 0
cc 9
eloc 25
nc 40
nop 0
1
<?php
2
3
namespace DoctrineElastic\Query;
4
5
use Doctrine\ORM\Query;
6
use Doctrine\ORM\Query\Parser;
7
use DoctrineElastic\DoctrineMock\GetConfigurationEntityManager;
8
use DoctrineElastic\Elastic\ElasticQuery;
9
10
/**
11
 * Elastic Query parser
12
 * Prepares query for execution
13
 *
14
 * @author Andsalves <[email protected]>
15
 */
16
class QueryParser {
17
18
    /** @var ElasticQuery */
19
    protected $query;
20
21
    /** @var Query\AST\SelectStatement */
22
    private $_ast;
23
24
    /** @var Parser */
25
    private $doctrineParser;
26
27
    public function __construct(ElasticQuery $query) {
28
        $this->query = $query;
29
30
        $doctrineQuery = new Query(new GetConfigurationEntityManager($query->getEntityManager()));
31
        $doctrineQuery->setDQL($query->getDQL());
32
        $this->doctrineParser = new Parser($doctrineQuery);
33
    }
34
35
    public function getAST() {
36
        if (is_null($this->_ast)) {
37
            $this->_ast = $this->doctrineParser->QueryLanguage();
38
        }
39
40
        return $this->_ast;
41
    }
42
43
    /**
44
     * Converts ElasticQuery to SearchParams
45
     *
46
     * @return \DoctrineElastic\Elastic\SearchParams
47
     */
48
    public function parseElasticQuery() {
49
        $outputWalker = new ElasticWalker($this->query, $this->getAST(), $this->getRootClass());
50
51
        return $outputWalker->walkSelectStatement();
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getRootClass() {
58
        /** @var \Doctrine\ORM\Query\AST\IdentificationVariableDeclaration[] $identificationVariableDeclarations */
59
        $identificationVariableDeclarations = $this->getAST()->fromClause->identificationVariableDeclarations;
60
61
        foreach ($identificationVariableDeclarations as $idVarDeclaration) {
62
            if ($idVarDeclaration->rangeVariableDeclaration->isRoot) {
63
                return $idVarDeclaration->rangeVariableDeclaration->abstractSchemaName;
64
            }
65
        }
66
67
        return reset($identificationVariableDeclarations)->rangeVariableDeclaration->abstractSchemaName;
68
    }
69
}
70