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 — develop ( df61b8...d9ddd1 )
by Toby
06:11
created

LogicRoleRepository::getById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\AssignRoles\Support;
4
5
use BristolSU\ControlDB\Contracts\Models\Role as RoleModel;
6
use BristolSU\ControlDB\Contracts\Repositories\Role;
7
use BristolSU\Support\Logic\Contracts\LogicRepository;
8
use BristolSU\Support\Logic\Facade\LogicTester;
9
use Illuminate\Support\Collection;
10
11
class LogicRoleRepository implements Role
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class LogicRoleRepository
Loading history...
12
{
13
14
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
15
     * @var Role
16
     */
17
    private $roleRepository;
0 ignored issues
show
Coding Style introduced by
Private member variable "roleRepository" must be prefixed with an underscore
Loading history...
18
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
19
     * @var \BristolSU\Support\Logic\Contracts\LogicTester
20
     */
21
    private $logicTester;
0 ignored issues
show
Coding Style introduced by
Private member variable "logicTester" must be prefixed with an underscore
Loading history...
22
23 38
    public function __construct(Role $roleRepository, \BristolSU\Support\Logic\Contracts\LogicTester $logicTester)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
24
    {
25 38
        $this->roleRepository = $roleRepository;
26 38
        $this->logicTester = $logicTester;
27 38
    }
28
29
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $id should have a doc-comment as per coding-style.
Loading history...
30
     * @inheritDoc
31
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
32 22
    public function getById(int $id): RoleModel
33
    {
34 22
        return $this->roleRepository->getById($id);
35
    }
36
37
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
38
     * @inheritDoc
39
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
40
    public function all(): Collection
41
    {
42
        return $this->filter($this->roleRepository->all());
43
    }
44
45
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $dataProviderId should have a doc-comment as per coding-style.
Loading history...
46
     * @inheritDoc
47
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
48
    public function getByDataProviderId(int $dataProviderId): RoleModel
49
    {
50
        return $this->roleRepository->getByDataProviderId($dataProviderId);
51
    }
52
53
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $positionId should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $groupId should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $dataProviderId should have a doc-comment as per coding-style.
Loading history...
54
     * @inheritDoc
55
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
56 6
    public function create(int $positionId, int $groupId, int $dataProviderId): RoleModel
57
    {
58 6
        return $this->roleRepository->create($positionId, $groupId, $dataProviderId);
59
    }
60
61
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $id should have a doc-comment as per coding-style.
Loading history...
62
     * @inheritDoc
63
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
64 1
    public function delete(int $id): void
65
    {
66 1
        $this->roleRepository->delete($id);
67 1
    }
68
69
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $group should have a doc-comment as per coding-style.
Loading history...
70
     * @inheritDoc
71
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
72 5
    public function allThroughGroup(\BristolSU\ControlDB\Contracts\Models\Group $group): Collection
73
    {
74 5
        return $this->filter($this->roleRepository->allThroughGroup($group));
75
76
    }
77
78
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $position should have a doc-comment as per coding-style.
Loading history...
79
     * @inheritDoc
80
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
81
    public function allThroughPosition(\BristolSU\ControlDB\Contracts\Models\Position $position): Collection
82
    {
83
        return $this->filter($this->roleRepository->allThroughPosition($position));
84
    }
85
86 5
    private function hasLogicGroup()
0 ignored issues
show
Coding Style introduced by
Private method name "LogicRoleRepository::hasLogicGroup" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function hasLogicGroup()
Loading history...
87
    {
88 5
        return $this->logicGroupId() !== null;
89
    }
90
91 5
    private function logicGroupId()
0 ignored issues
show
Coding Style introduced by
Private method name "LogicRoleRepository::logicGroupId" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function logicGroupId()
Loading history...
92
    {
93 5
        $id = settings('logic_group', null);
94 5
        if($id === null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
95 4
            return null;
96
        }
97 1
        return (int) $id;
98
    }
99
100 1
    private function logicGroup()
0 ignored issues
show
Coding Style introduced by
Private method name "LogicRoleRepository::logicGroup" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function logicGroup()
Loading history...
101
    {
102 1
        return app(LogicRepository::class)->getById(
103 1
            $this->logicGroupId()
0 ignored issues
show
Bug introduced by
It seems like $this->logicGroupId() can also be of type null; however, parameter $id of BristolSU\Support\Logic\...icRepository::getById() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

103
            /** @scrutinizer ignore-type */ $this->logicGroupId()
Loading history...
104
        );
105
    }
106
    
107 1
    private function isInLogicGroup(\BristolSU\ControlDB\Contracts\Models\Role $role)
0 ignored issues
show
Coding Style introduced by
Private method name "LogicRoleRepository::isInLogicGroup" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function isInLogicGroup()
Loading history...
108
    {
109 1
        return $this->logicTester->evaluate($this->logicGroup(), null, $role->group(), $role);
110
    }
111
112 5
    private function filter(Collection $roles)
0 ignored issues
show
Coding Style introduced by
Private method name "LogicRoleRepository::filter" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function filter()
Loading history...
113
    {
114 5
        if($this->hasLogicGroup()) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
115
            return $roles->filter(function(\BristolSU\ControlDB\Contracts\Models\Role $role) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
116 1
                return $this->isInLogicGroup($role);
117 1
            })->values();
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
118
        }
119 4
        return $roles;
120
    }
121
}