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.

Group::all()   A
last analyzed

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
eloc 1
c 1
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\Cache;
4
5
use BristolSU\ControlDB\Contracts\Models\Group as GroupModel;
6
use BristolSU\ControlDB\Contracts\Repositories\Group as GroupRepositoryContract;
7
use BristolSU\ControlDB\Contracts\Repositories\Group as GroupRepository;
8
use Illuminate\Contracts\Cache\Repository;
9
use Illuminate\Support\Collection;
10
11
class Group implements GroupRepository
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Group
Loading history...
12
{
13
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
14
     * @var GroupRepositoryContract
15
     */
16
    private $groupRepository;
0 ignored issues
show
Coding Style introduced by
Private member variable "groupRepository" must be prefixed with an underscore
Loading history...
17
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
18
     * @var Repository
19
     */
20
    private $cache;
0 ignored issues
show
Coding Style introduced by
Private member variable "cache" must be prefixed with an underscore
Loading history...
21
22 44
    public function __construct(GroupRepositoryContract $groupRepository, Repository $cache)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
23
    {
24 44
        $this->groupRepository = $groupRepository;
25 44
        $this->cache = $cache;
26 44
    }
27
28
    /**
29
     * Get a group by ID
30
     *
31
     * @param int $id ID of the group
32
     * @return GroupModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
33
     */
34 27
    public function getById(int $id): GroupModel
35
    {
36
        return $this->cache->rememberForever(static::class . '@getById:' . $id, function() use ($id) {
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...
37 27
            return $this->groupRepository->getById($id);
38 27
        });
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...
39
    }
40
41
    /**
42
     * Get a group by its data provider ID
43
     *
44
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
45
     * @return GroupModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
46
     */
47 3
    public function getByDataProviderId(int $dataProviderId): GroupModel
48
    {
49
        return $this->cache->rememberForever(static::class . '@getByDataProviderId:' . $dataProviderId, function() use ($dataProviderId) {
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...
50 3
            return $this->groupRepository->getByDataProviderId($dataProviderId);
51 3
        });
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...
52
    }
53
54
    /**
55
     * Get all groups
56
     *
57
     * @return Collection|GroupModel[]
58
     */
59 2
    public function all(): Collection
60
    {
61 2
        return $this->groupRepository->all();
62
    }
63
64
    /**
65
     * Create a new group
66
     *
67
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
68
     * @return GroupModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
69
     */
70 3
    public function create(int $dataProviderId): GroupModel
71
    {
72 3
        return $this->groupRepository->create($dataProviderId);
73
    }
74
75
    /**
76
     * Delete a group by ID
77
     *
78
     * @param int $id
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
79
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
80 2
    public function delete(int $id): void
81
    {
82 2
        $this->groupRepository->delete($id);
83 2
    }
84
85
    /**
86
     * Paginate through all the groups
87
     *
88
     * @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...
89
     * @param int $perPage The number of results to return per page
90
     *
91
     * @return Collection|GroupModel[]
92
     */
93 3
    public function paginate(int $page, int $perPage): Collection
94
    {
95 3
        return $this->groupRepository->paginate($page, $perPage);
96
    }
97
98
    /**
99
     * Get the number of groups
100
     *
101
     * @return int
102
     */
103 3
    public function count(): int
104
    {
105
        return $this->cache->rememberForever(static::class . '@count', function() {
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...
106 3
            return $this->groupRepository->count();
107 3
        });
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...
108
    }
109
110
    /**
111
     * Update the group model
112
     *
113
     * @param int $id 
114
     * @param int $dataProviderId New data provider ID
115
     * @return GroupModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
116
     */
117 2
    public function update(int $id, int $dataProviderId): GroupModel
118
    {
119 2
        return $this->groupRepository->update($id, $dataProviderId);
120
    }
121
}