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 ( a11bd1...3fc1f5 )
by Anderson
02:01
created

QueryParser::getRootClass()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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