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 (#14)
by Toby
31:11 queued 12:50
created

User   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 16
c 1
b 0
f 0
dl 0
loc 109
ccs 24
cts 24
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getByDataProviderId() 0 4 1
A getById() 0 4 1
A create() 0 3 1
A __construct() 0 4 1
A paginate() 0 3 1
A update() 0 3 1
A all() 0 3 1
A count() 0 4 1
A delete() 0 3 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\User as UserModel;
6
use BristolSU\ControlDB\Contracts\Repositories\User as UserRepositoryContract;
7
use BristolSU\ControlDB\Contracts\Repositories\User as UserRepository;
8
use Illuminate\Contracts\Cache\Repository;
9
use Illuminate\Support\Collection;
10
11
class User implements UserRepository
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class User
Loading history...
12
{
13
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
14
     * @var UserRepositoryContract
15
     */
16
    private $userRepository;
0 ignored issues
show
Coding Style introduced by
Private member variable "userRepository" 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 54
    public function __construct(UserRepositoryContract $userRepository, Repository $cache)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
23
    {
24 54
        $this->userRepository = $userRepository;
25 54
        $this->cache = $cache;
26 54
    }
27
28
    /**
29
     * Get a user by ID
30
     *
31
     * @param int $id ID of the user
32
     * @return UserModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
33
     */
34 36
    public function getById(int $id): UserModel
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 36
            return $this->userRepository->getById($id);
38 36
        });
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 user 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 UserModel
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): UserModel
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->userRepository->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 users
56
     *
57
     * @return Collection|UserModel[]
58
     */
59 2
    public function all(): Collection
60
    {
61 2
        return $this->userRepository->all();
62
    }
63
64
    /**
65
     * Create a new user
66
     *
67
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
68
     * @return UserModel
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): UserModel
71
    {
72 3
        return $this->userRepository->create($dataProviderId);
73
    }
74
75
    /**
76
     * Delete a user 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->userRepository->delete($id);
83 2
    }
84
85
    /**
86
     * Paginate through all the users
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|UserModel[]
92
     */
93 3
    public function paginate(int $page, int $perPage): Collection
94
    {
95 3
        return $this->userRepository->paginate($page, $perPage);
96
    }
97
98
    /**
99
     * Get the number of users
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->userRepository->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 user model
112
     *
113
     * @param int $id
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
114
     * @param int $dataProviderId New data provider ID
115
     * @return UserModel
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): UserModel
118
    {
119 2
        return $this->userRepository->update($id, $dataProviderId);
120
    }
121
}