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   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 44
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A getRepository() 0 13 1
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