1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | namespace BristolSU\ControlDB\Cache; |
||
4 | |||
5 | use BristolSU\ControlDB\Contracts\Repositories\DataPosition as DataPositionRepository; |
||
6 | use Illuminate\Contracts\Cache\Repository; |
||
7 | use Illuminate\Support\Collection; |
||
8 | |||
9 | class DataPosition implements DataPositionRepository |
||
0 ignored issues
–
show
|
|||
10 | { |
||
11 | |||
12 | /** |
||
0 ignored issues
–
show
|
|||
13 | * @var DataPositionRepository |
||
14 | */ |
||
15 | private $dataPositionRepository; |
||
0 ignored issues
–
show
|
|||
16 | /** |
||
0 ignored issues
–
show
|
|||
17 | * @var Repository |
||
18 | */ |
||
19 | private $cache; |
||
0 ignored issues
–
show
|
|||
20 | |||
21 | 18 | public function __construct(DataPositionRepository $dataPositionRepository, Repository $cache) |
|
0 ignored issues
–
show
|
|||
22 | { |
||
23 | 18 | $this->dataPositionRepository = $dataPositionRepository; |
|
24 | 18 | $this->cache = $cache; |
|
25 | 18 | } |
|
26 | |||
27 | /** |
||
28 | * Get a data position by ID |
||
29 | * |
||
30 | * @param int $id |
||
0 ignored issues
–
show
|
|||
31 | * @return \BristolSU\ControlDB\Contracts\Models\DataPosition |
||
0 ignored issues
–
show
|
|||
32 | */ |
||
33 | 12 | public function getById(int $id): \BristolSU\ControlDB\Contracts\Models\DataPosition |
|
34 | { |
||
35 | return $this->cache->rememberForever(static::class . '@getById:' . $id, function() use ($id) { |
||
0 ignored issues
–
show
|
|||
36 | 12 | return $this->dataPositionRepository->getById($id); |
|
37 | 12 | }); |
|
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.
![]() |
|||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Get a data position where the given attributes match, including additional attributes. |
||
42 | * |
||
43 | * @param array $attributes |
||
0 ignored issues
–
show
|
|||
44 | * @return \BristolSU\ControlDB\Contracts\Models\DataPosition |
||
0 ignored issues
–
show
|
|||
45 | */ |
||
46 | 1 | public function getWhere($attributes = []): \BristolSU\ControlDB\Contracts\Models\DataPosition |
|
47 | { |
||
48 | 1 | return $this->dataPositionRepository->getWhere($attributes); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Get all data positions where the given attributes match, including additional attributes. |
||
53 | * |
||
54 | * @param array $attributes |
||
0 ignored issues
–
show
|
|||
55 | * @return Collection|\BristolSU\ControlDB\Contracts\Models\DataPosition[] |
||
0 ignored issues
–
show
|
|||
56 | */ |
||
57 | 1 | public function getAllWhere($attributes = []): Collection |
|
58 | { |
||
59 | 1 | return $this->dataPositionRepository->getAllWhere($attributes); |
|
60 | } |
||
61 | |||
62 | |||
63 | /** |
||
64 | * Create a data position with the given attributes |
||
65 | * |
||
66 | * @param string|null $name Name of the position |
||
0 ignored issues
–
show
|
|||
67 | * @param string|null $description Description of the position |
||
68 | * @return \BristolSU\ControlDB\Contracts\Models\DataPosition |
||
0 ignored issues
–
show
|
|||
69 | */ |
||
70 | 3 | public function create(?string $name = null, ?string $description = null): \BristolSU\ControlDB\Contracts\Models\DataPosition |
|
71 | { |
||
72 | 3 | return $this->dataPositionRepository->create($name, $description); |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * Update a data position with the given attributes |
||
77 | * |
||
78 | * @param int $id |
||
0 ignored issues
–
show
|
|||
79 | * @param string|null $name Name of the position |
||
0 ignored issues
–
show
|
|||
80 | * @param string|null $description Description of the position |
||
81 | * @return \BristolSU\ControlDB\Contracts\Models\DataPosition |
||
0 ignored issues
–
show
|
|||
82 | */ |
||
83 | 5 | public function update(int $id, ?string $name = null, ?string $description = null): \BristolSU\ControlDB\Contracts\Models\DataPosition |
|
84 | { |
||
85 | 5 | return $this->dataPositionRepository->update($id, $name, $description); |
|
86 | } |
||
87 | } |