Passed
Push — master ( a3d690...784c7b )
by Julito
08:24
created

NonResourceRepository::getResourceNodeRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Traits;
8
9
use Chamilo\CoreBundle\Repository\ResourceNodeRepository;
10
use Chamilo\CoreBundle\ToolChain;
11
use Cocur\Slugify\SlugifyInterface;
12
use Doctrine\ORM\EntityManager;
13
use Doctrine\ORM\EntityRepository;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\RequestStack;
16
use Symfony\Component\Routing\RouterInterface;
17
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
18
19
trait NonResourceRepository
20
{
21
    protected EntityRepository $repository;
22
23
    protected EntityManager $entityManager;
24
25
    protected ?RouterInterface $router = null;
26
27
    protected ?ResourceNodeRepository $resourceNodeRepository = null;
28
29
    protected ?AuthorizationCheckerInterface $authorizationChecker = null;
30
31
    protected ?SlugifyInterface $slugify = null;
32
33
    protected ?ToolChain $toolChain = null;
34
35
    protected ?RequestStack $requestStack;
36
37
    public function getAuthorizationChecker(): AuthorizationCheckerInterface
38
    {
39
        return $this->authorizationChecker;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->authorizationChecker could return the type null which is incompatible with the type-hinted return Symfony\Component\Securi...izationCheckerInterface. Consider adding an additional type-check to rule them out.
Loading history...
40
    }
41
42
    public function setAuthorizationChecker(AuthorizationCheckerInterface $authorizationChecker): self
43
    {
44
        $this->authorizationChecker = $authorizationChecker;
45
46
        return $this;
47
    }
48
49
    public function getRouter(): RouterInterface
50
    {
51
        return $this->router;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->router could return the type null which is incompatible with the type-hinted return Symfony\Component\Routing\RouterInterface. Consider adding an additional type-check to rule them out.
Loading history...
52
    }
53
54
    public function setRouter(RouterInterface $router): self
55
    {
56
        $this->router = $router;
57
58
        return $this;
59
    }
60
61
    public function setSlugify(SlugifyInterface $slugify): self
62
    {
63
        $this->slugify = $slugify;
64
65
        return $this;
66
    }
67
68
    public function setToolChain(ToolChain $toolChain): self
69
    {
70
        $this->toolChain = $toolChain;
71
72
        return $this;
73
    }
74
75
    /**
76
     * @return ResourceNodeRepository
77
     */
78
    public function getResourceNodeRepository()
79
    {
80
        return $this->resourceNodeRepository;
81
    }
82
83
    public function setResourceNodeRepository(ResourceNodeRepository $resourceNodeRepository): self
84
    {
85
        $this->resourceNodeRepository = $resourceNodeRepository;
86
87
        return $this;
88
    }
89
    public function setRequestStack(RequestStack $requestStack): self
90
    {
91
        $this->requestStack = $requestStack;
92
93
        return $this;
94
    }
95
96
    public function getRequest(): Request
97
    {
98
        return $this->requestStack->getCurrentRequest();
0 ignored issues
show
Bug introduced by
The method getCurrentRequest() 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

98
        return $this->requestStack->/** @scrutinizer ignore-call */ getCurrentRequest();

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...
99
    }
100
}
101