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.

Position::getById()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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