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.
Passed
Push — master ( cede11...e553e5 )
by Alessandro
08:40 queued 05:22
created

AbstractQuery   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 41.94%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 67
ccs 13
cts 31
cp 0.4194
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntityName() 0 3 1
A __construct() 0 4 1
A loadMetadataAndOptions() 0 12 1
A createQueryBuilder() 0 8 1
A createSelectAndGroupBy() 0 11 1
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 50
    public function __construct(EntityManager $manager)
23
    {
24 50
        $this->manager = $manager;
25 50
        $this->parser  = new StringParser();
26 50
    }
27
28
    public function createSelectAndGroupBy($entityName, $alias, $groupByField)
29
    {
30
        $select = $alias . '.' . $groupByField . ', count(' . $alias . '.id) as num';
31
        $groupBy = $alias . '.' . $groupByField . '';
32
33
        $this->entityName = $entityName;
34
        $this->entityAlias = $alias;
35
36
        $this->qBuilder = $this->manager->createQueryBuilder()
37
            ->select($select)
38
            ->groupBy($groupBy);
39
    }
40
41 25
    public function createQueryBuilder($entityName, $alias)
42
    {
43 25
        $this->entityName = $entityName;
44 25
        $this->entityAlias = $alias;
45
46 25
        $this->qBuilder = $this->manager->createQueryBuilder()
47 25
            ->select($alias)
48 25
            ->from($this->entityName, $alias);
49 25
    }
50
51 11
    public function getEntityName()
52
    {
53 11
        return $this->entityName;
54
    }
55
56
    public function loadMetadataAndOptions(
57
        MetaDataAdapter $metadata,
58
        QueryBuilderOptions $options
59
    ) {
60
        $this->setFields($metadata->getFields());
61
62
        $this->setAndFilters($options->getAndFilters());
63
        $this->setOrFilters($options->getOrFilters());
64
        $this->setSorting($options->getSorting());
65
        $this->setRel([$options->getRel()]);
66
        $this->setPrinting($options->getPrinting());
67
        $this->setSelect($options->getSelect());
68
    }
69
70
    abstract public function setFields(array $fields = []);
71
    abstract public function setAndFilters(array $andFilters = []);
72
    abstract public function setOrFilters(array $orFilters = []);
73
    abstract public function setSorting(array $sorting = []);
74
    abstract public function setRel(array $rel);
75
    abstract public function setPrinting($printing);
76
    abstract public function setSelect($select);
77
}
78