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 — refactoring/additional-filters... ( 3765eb...d5ee27 )
by Simone
02:36
created

QueryBuilder::getRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Mado\QueryBundle\Services;
4
5
use Doctrine\ORM\EntityManager;
6
use Mado\QueryBundle\Interfaces\CustomFilter;
7
use Psr\Log\LoggerInterface;
8
use Symfony\Component\HttpFoundation\RequestStack;
9
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...en\Storage\TokenStorage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
final class QueryBuilder
12
{
13
    private $customFilter;
14
15
    private $storage;
16
17
    private $token;
18
19
    private $user;
20
21
    private $request;
22
23
    private $logger;
24
25
    public function __construct(
26
        CustomFilter $customFilter,
27
        TokenStorage $storage,
28
        EntityManager $manager,
29
        RequestStack $requestStack,
30
        LoggerInterface $logger
31
    ) {
32
        $this->customFilter = $customFilter;
33
        $this->storage      = $storage;
34
        $this->manager      = $manager;
0 ignored issues
show
Bug Best Practice introduced by
The property manager does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
        $this->request      = $requestStack->getCurrentRequest();
36
        $this->logger       = $logger;
37
38
        $this->token = $this->storage->getToken();
39
        $this->user  = $this->token->getUser();
40
    }
41
42
    public function getRepository(string $rootEntity)
43
    {
44
        $this->rootEntity = $rootEntity;
0 ignored issues
show
Bug Best Practice introduced by
The property rootEntity does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
45
46
        $additionalFilters = $this->customFilter
47
            ->setUser($this->user)
48
            ->allItemsTo($rootEntity);
49
50
        return $this->manager
51
            ->getRepository($this->rootEntity)
52
            ->setRequestWithFilter(
53
                $this->request,
54
                $additionalFilters
55
            );
56
    }
57
}
58