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 — fix/default_value ( e9524c )
by
unknown
33s
created

AbstractQuery::loadMetadataAndOptions()   A

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
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
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
class AbstractQuery
11
{
12
    protected $manager;
13
14
    protected $entityName;
15
16
    protected $entityAlias;
17
18
    protected $parser;
19
20
    protected $qBuilder;
21
22 40
    public function __construct(EntityManager $manager)
23
    {
24 40
        $this->manager = $manager;
25 40
        $this->parser  = new StringParser();
26 40
    }
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($this->entityName)
0 ignored issues
show
Unused Code introduced by
The call to Doctrine\ORM\EntityManager::createQueryBuilder() has too many arguments starting with $this->entityName. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        $this->qBuilder = $this->manager->/** @scrutinizer ignore-call */ createQueryBuilder($this->entityName)

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
37
            ->select($select)
38
            ->groupBy($groupBy);
39
    }
40
41 15
    public function createQueryBuilder($entityName, $alias)
42
    {
43 15
        $this->entityName = $entityName;
44 15
        $this->entityAlias = $alias;
45
46 15
        $this->qBuilder = $this->manager->createQueryBuilder($this->entityName)
0 ignored issues
show
Unused Code introduced by
The call to Doctrine\ORM\EntityManager::createQueryBuilder() has too many arguments starting with $this->entityName. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
        $this->qBuilder = $this->manager->/** @scrutinizer ignore-call */ createQueryBuilder($this->entityName)

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
47 15
            ->select($alias)
48 15
            ->from($this->entityName, $alias);
49 15
    }
50
51 5
    public function getEntityName()
52
    {
53 5
        return $this->entityName;
54
    }
55
56
    public function loadMetadataAndOptions(
57
        MetaDataAdapter $metadata,
58
        QueryBuilderOptions $options
59
    ) {
60
        $this->setFields($metadata->getFields());
0 ignored issues
show
introduced by
The method setFields() does not exist on Mado\QueryBundle\Queries\AbstractQuery. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
        $this->/** @scrutinizer ignore-call */ 
61
               setFields($metadata->getFields());
Loading history...
61
62
        $this->setAndFilters($options->getAndFilters());
0 ignored issues
show
introduced by
The method setAndFilters() does not exist on Mado\QueryBundle\Queries\AbstractQuery. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

62
        $this->/** @scrutinizer ignore-call */ 
63
               setAndFilters($options->getAndFilters());
Loading history...
63
        $this->setOrFilters($options->getOrFilters());
0 ignored issues
show
introduced by
The method setOrFilters() does not exist on Mado\QueryBundle\Queries\AbstractQuery. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
        $this->/** @scrutinizer ignore-call */ 
64
               setOrFilters($options->getOrFilters());
Loading history...
64
        $this->setSorting($options->getSorting());
0 ignored issues
show
introduced by
The method setSorting() does not exist on Mado\QueryBundle\Queries\AbstractQuery. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
        $this->/** @scrutinizer ignore-call */ 
65
               setSorting($options->getSorting());
Loading history...
65
        $this->setRel($options->getRel());
0 ignored issues
show
introduced by
The method setRel() does not exist on Mado\QueryBundle\Queries\AbstractQuery. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
        $this->/** @scrutinizer ignore-call */ 
66
               setRel($options->getRel());
Loading history...
66
        $this->setPrinting($options->getPrinting());
0 ignored issues
show
introduced by
The method setPrinting() does not exist on Mado\QueryBundle\Queries\AbstractQuery. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

66
        $this->/** @scrutinizer ignore-call */ 
67
               setPrinting($options->getPrinting());
Loading history...
67
        $this->setSelect($options->getSelect());
0 ignored issues
show
introduced by
The method setSelect() does not exist on Mado\QueryBundle\Queries\AbstractQuery. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

67
        $this->/** @scrutinizer ignore-call */ 
68
               setSelect($options->getSelect());
Loading history...
68
    }
69
}
70