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 (#13)
by Toby
16:48 queued 03:24
created

Role::paginate()   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 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
namespace BristolSU\ControlDB\Repositories;
5
6
7
8
use BristolSU\ControlDB\Contracts\Models\Role as RoleModel;
9
use BristolSU\ControlDB\Contracts\Repositories\Role as RoleContract;
10
use Illuminate\Support\Collection;
11
12
/**
13
 * Class Role
14
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
15
class Role implements RoleContract
16
{
17
18
19
    /**
20
     * Get a role by ID
21
     *
22
     * @param int $id
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
23
     * @return RoleModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
24
     */
25 25
    public function getById(int $id): \BristolSU\ControlDB\Contracts\Models\Role
26
    {
27 25
        return \BristolSU\ControlDB\Models\Role::findOrFail($id);
28
    }
29
30
    /**
31
     * Get all roles
32
     *
33
     * @return Collection|\BristolSU\ControlDB\Contracts\Models\Role[]
34
     */
35 2
    public function all(): Collection
36
    {
37 2
        return \BristolSU\ControlDB\Models\Role::all();
38
    }
39
40
    /**
41
     * Create a new role
42
     *
43
     * @param int $positionId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
44
     * @param int $groupId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
45
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
46
     * @return RoleModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
47
     */
48 4
    public function create(int $positionId, int $groupId, int $dataProviderId): \BristolSU\ControlDB\Contracts\Models\Role
49
    {
50 4
        return \BristolSU\ControlDB\Models\Role::create([
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...
51 4
            'position_id' => $positionId,
52 4
            'group_id' => $groupId,
53 4
            'data_provider_id' => $dataProviderId
54
        ]);
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...
55
    }
56
57
    /**
58
     * Delete a role
59
     *
60
     * @param int $id
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
61
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
62 2
    public function delete(int $id): void
63
    {
64 2
        $this->getById($id)->delete();
65 2
    }
66
67
    /**
68
     * Get a role by data provider ID
69
     *
70
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
71
     * @return RoleModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
72
     */
73 4
    public function getByDataProviderId(int $dataProviderId): \BristolSU\ControlDB\Contracts\Models\Role {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
74 4
        return \BristolSU\ControlDB\Models\Role::where('data_provider_id', $dataProviderId)->firstOrFail();
75
    }
76
    
77
    /**
78
     * Get all roles that belong to the given group
79
     *
80
     * @param \BristolSU\ControlDB\Contracts\Models\Group $group
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
81
     * @return Collection|RoleModel[]
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
82
     */
83 4
    public function allThroughGroup(\BristolSU\ControlDB\Contracts\Models\Group $group): Collection
84
    {
85 4
        return \BristolSU\ControlDB\Models\Role::where('group_id', $group->id())->get();
86
    }
87
88
    /**
89
     * Get all roles that belong to the given position
90
     * @param \BristolSU\ControlDB\Contracts\Models\Position $position
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
91
     * @return Collection|RoleModel[]
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
92
     */
93 4
    public function allThroughPosition(\BristolSU\ControlDB\Contracts\Models\Position $position): Collection
94
    {
95 4
        return \BristolSU\ControlDB\Models\Role::where('position_id', $position->id())->get();
96
    }
97
98
    /**
99
     * Paginate through all the roles
100
     *
101
     * @param int $page The page number to return
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter name; 1 found
Loading history...
102
     * @param int $perPage The number of results to return per page
103
     *
104
     * @return Collection|RoleModel[]
105
     */
106 3
    public function paginate(int $page, int $perPage): Collection
107
    {
108 3
        return \BristolSU\ControlDB\Models\Role::paginate($perPage, ['*'], 'page', $page)->getCollection();
109
    }
110
111
    /**
112
     * Get the number of roles
113
     *
114
     * @return int
115
     */
116 3
    public function count(): int
117
    {
118 3
        return \BristolSU\ControlDB\Models\Role::count();
0 ignored issues
show
Bug Best Practice introduced by
The expression return BristolSU\ControlDB\Models\Role::count() could return the type Illuminate\Database\Eloquent\Builder which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
119
    }
120
}
121