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.

Issues (4568)

src/Repositories/Role.php (30 issues)

1
<?php
2
0 ignored issues
show
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
Missing @category tag in class comment
Loading history...
Missing @package tag in class comment
Loading history...
Missing @author tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
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
Missing parameter comment
Loading history...
23
     * @return RoleModel
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
24
     */
25 30
    public function getById(int $id): \BristolSU\ControlDB\Contracts\Models\Role
26
    {
27 30
        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
Missing parameter comment
Loading history...
44
     * @param int $groupId
0 ignored issues
show
Missing parameter comment
Loading history...
45
     * @param int $dataProviderId
0 ignored issues
show
Missing parameter comment
Loading history...
46
     * @return RoleModel
0 ignored issues
show
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
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
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
Missing parameter comment
Loading history...
61
     */
0 ignored issues
show
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
Missing parameter comment
Loading history...
71
     * @return RoleModel
0 ignored issues
show
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
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
Missing parameter comment
Loading history...
81
     * @return Collection|RoleModel[]
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
82
     */
83 5
    public function allThroughGroup(\BristolSU\ControlDB\Contracts\Models\Group $group): Collection
84
    {
85 5
        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
There must be exactly one blank line before the tags in a doc comment
Loading history...
Missing parameter comment
Loading history...
91
     * @return Collection|RoleModel[]
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
92
     */
93 5
    public function allThroughPosition(\BristolSU\ControlDB\Contracts\Models\Position $position): Collection
94
    {
95 5
        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
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
    /**
122
     * Update the role model
123
     *
124
     * @param int $id
0 ignored issues
show
Missing parameter comment
Loading history...
125
     * @param int $positionId
0 ignored issues
show
Missing parameter comment
Loading history...
126
     * @param int $groupId
0 ignored issues
show
Missing parameter comment
Loading history...
127
     * @param int $dataProviderId New data provider ID
128
     * @return RoleModel
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
129
     */
130 7
    public function update(int $id, int $positionId, int $groupId, int $dataProviderId): RoleModel
131
    {
132 7
        $role = $this->getById($id)->fill(['position_id' => $positionId, 'group_id' => $groupId, 'data_provider_id' => $dataProviderId]);
133 7
        $role->save();
134 7
        return $role;
135
    }
136
}
137