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

Group::count()   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 0
crap 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Repositories;
4
5
use BristolSU\ControlDB\Contracts\Models\Group as GroupModel;
6
use BristolSU\ControlDB\Contracts\Repositories\Group as GroupContract;
7
use Illuminate\Support\Collection;
8
9
/**
10
 * Handles groups
11
 */
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...
12
class Group implements GroupContract
13
{
14
15
    /**
16
     * Get a group by ID
17
     *
18
     * @param int $id ID of the group
0 ignored issues
show
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
19
     * @return GroupModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
20
     */
21 28
    public function getById(int $id): GroupModel
22
    {
23 28
        return \BristolSU\ControlDB\Models\Group::findOrFail($id);
24
    }
25
26
    /**
27
     * Get all groups
28
     *
29
     * @return Collection|GroupModel[]
30
     */
31 2
    public function all(): Collection
32
    {
33 2
        return \BristolSU\ControlDB\Models\Group::all();
34
    }
35
36
    /**
37
     * Create a new group
38
     *
39
     * @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...
40
     * @return GroupModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
41
     */
42 4
    public function create(int $dataProviderId): GroupModel
43
    {
44 4
        return \BristolSU\ControlDB\Models\Group::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...
45 4
            'data_provider_id' => $dataProviderId
46
        ]);
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...
47
    }
48
49
    /**
50
     * Delete a group by ID
51
     *
52
     * @param int $id
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
53
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
54 2
    public function delete(int $id): void
55
    {
56 2
        \BristolSU\ControlDB\Models\Group::findOrFail($id)->delete();
57 2
    }
58
59
    /**
60
     * Get a group by its data provider ID
61
     *
62
     * @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...
63
     * @return GroupModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
64
     */
65 4
    public function getByDataProviderId(int $dataProviderId): GroupModel {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
66 4
        return \BristolSU\ControlDB\Models\Group::where('data_provider_id', $dataProviderId)->firstOrFail();
67
    }
68
69
    /**
70
     * Paginate through all the groups
71
     *
72
     * @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...
73
     * @param int $perPage The number of results to return per page
74
     *
75
     * @return Collection|GroupModel[]
76
     */
77 3
    public function paginate(int $page, int $perPage): Collection
78
    {
79 3
        return \BristolSU\ControlDB\Models\Group::paginate($perPage, ['*'], 'page', $page)->getCollection();
80
    }
81
82
    /**
83
     * Get the number of groups
84
     *
85
     * @return int
86
     */
87 3
    public function count(): int
88
    {
89 3
        return \BristolSU\ControlDB\Models\Group::count();
0 ignored issues
show
Bug Best Practice introduced by
The expression return BristolSU\ControlDB\Models\Group::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...
90
    }
91
92
}
93