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
Pull Request — master (#61)
by Simone
02:25
created

ConfigProvider   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setDomainConfiguration() 0 3 1
A getRequest() 0 3 1
A filterRelation() 0 21 3
A __construct() 0 9 1
A getUserRoles() 0 3 1
A getConf() 0 3 1
A getUser() 0 3 1
1
<?php
2
namespace Mado\QueryBundle\Services;
3
4
use Doctrine\ORM\EntityManager;
5
use Doctrine\ORM\QueryBuilder;
6
use Mado\QueryBundle\Component\ConfigProvider as ConfigProviderInterface;
7
use Symfony\Component\HttpFoundation\RequestStack;
8
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
9
10
class ConfigProvider implements ConfigProviderInterface
11
{
12
    private $user;
13
14
    private $request;
15
16
    private $manager;
17
18
    private $domainConfiguration;
19
20
    public function __construct(
21
        RequestStack $requestStack,
22
        TokenStorage $tokenStorage,
23
        EntityManager $manager
24
    ) {
25
        $this->token   = $tokenStorage->getToken();
0 ignored issues
show
Bug Best Practice introduced by
The property token does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
        $this->user    = $this->token->getUser();
0 ignored issues
show
Bug introduced by
The method getUser() does not exist on null. ( Ignorable by Annotation )

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

26
        /** @scrutinizer ignore-call */ 
27
        $this->user    = $this->token->getUser();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        $this->request = $requestStack->getCurrentRequest();
28
        $this->manager = $manager;
29
    }
30
31
    public function setDomainConfiguration(array $domainConfiguration = [])
32
    {
33
        $this->domainConfiguration = $domainConfiguration;
34
    }
35
36
    public function getConf()
37
    {
38
        return $this->domainConfiguration;
39
    }
40
41
    public function getUser()
42
    {
43
        return $this->user;
44
    }
45
46
    public function getRequest()
47
    {
48
        return $this->request;
49
    }
50
51
    public function getUserRoles()
52
    {
53
        return $this->token->getRoles();
54
    }
55
56
    public function filterRelation(QueryBuilder $qb)
57
    {
58
        $conf = $this->getConf();
59
60
        foreach ($conf['additional-filters'] as $entityClass => $entityIds) {
61
            if (isset($conf['entity-map'][$conf['root-entity']])) {
62
                $relationName = $conf['entity-map'][$conf['root-entity']];
63
64
                $qb->andWhere(
65
                    $qb->expr()->in(
66
                        $qb->getRootAlias() . '.' . $relationName[$entityClass],
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\ORM\QueryBuilder::getRootAlias() has been deprecated: Please use $qb->getRootAliases() instead. ( Ignorable by Annotation )

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

66
                        /** @scrutinizer ignore-deprecated */ $qb->getRootAlias() . '.' . $relationName[$entityClass],

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
67
                        $entityIds
68
                    )
69
                );
70
71
                var_dump($qb->getQuery()->getDql());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($qb->getQuery()->getDql()) looks like debug code. Are you sure you do not want to remove it?
Loading history...
72
                die;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
73
            }
74
        }
75
76
        return $qb;
77
    }
78
}
79