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.

AbstractQuery::loadMetadataAndOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
c 0
b 0
f 0
ccs 0
cts 8
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Mado\QueryBundle\Queries;
4
5
use Doctrine\ORM\EntityManager;
6
use Mado\QueryBundle\Objects\MetaDataAdapter;
7
use Mado\QueryBundle\Queries\QueryBuilderOptions;
8
use Mado\QueryBundle\Services\StringParser;
9
10
abstract class AbstractQuery
11
{
12
    protected $manager;
13
14
    protected $entityName;
15
16
    protected $entityAlias;
17
18
    protected $parser;
19
20
    protected $qBuilder;
21
22
    protected $joinFactory;
23
24 52
    public function __construct(EntityManager $manager)
25
    {
26 52
        $this->manager = $manager;
27 52
        $this->parser  = new StringParser();
28 52
    }
29
30
    public function createSelectAndGroupBy($entityName, $alias, $groupByField)
31
    {
32
        $select = $alias . '.' . $groupByField . ', count(' . $alias . '.id) as num';
33
        $groupBy = $alias . '.' . $groupByField . '';
34
35
        $this->entityName = $entityName;
36
        $this->entityAlias = $alias;
37
38
        $this->qBuilder = $this->manager->createQueryBuilder()
39
            ->select($select)
40
            ->groupBy($groupBy);
41
42
        $this->joinFactory = new Join($this->getEntityName(), $this->entityAlias, $this->manager);
43
    }
44
45 27
    public function createQueryBuilder($entityName, $alias)
46
    {
47 27
        $this->entityName = $entityName;
48 27
        $this->entityAlias = $alias;
49
50 27
        $this->qBuilder = $this->manager->createQueryBuilder()
51 27
            ->select($alias)
52 27
            ->from($this->entityName, $alias);
53
54 27
        $this->joinFactory = new Join($this->getEntityName(), $this->entityAlias, $this->manager);
55 27
    }
56
57 27
    public function getEntityName()
58
    {
59 27
        return $this->entityName;
60
    }
61
62
    public function loadMetadataAndOptions(
63
        MetaDataAdapter $metadata,
64
        QueryBuilderOptions $options
65
    ) {
66
        $this->setFields($metadata->getFields());
67
68
        $this->setAndFilters($options->getAndFilters());
69
        $this->setOrFilters($options->getOrFilters());
70
        $this->setSorting($options->getSorting());
71
        $this->setRel([$options->getRel()]);
72
        $this->setPrinting($options->getPrinting());
73
        $this->setSelect($options->getSelect());
74
    }
75
76
    abstract public function setFields(array $fields = []);
77
    abstract public function setAndFilters(array $andFilters = []);
78
    abstract public function setOrFilters(array $orFilters = []);
79
    abstract public function setSorting(array $sorting = []);
80
    abstract public function setRel(array $rel);
81
    abstract public function setPrinting($printing);
82
    abstract public function setSelect($select);
83
}
84