1 | <?php |
||||
2 | |||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||
3 | |||||
4 | namespace BristolSU\ControlDB\Traits; |
||||
5 | |||||
6 | |||||
7 | use BristolSU\ControlDB\Contracts\Models\Position; |
||||
8 | use BristolSU\ControlDB\Contracts\Repositories\DataPosition; |
||||
9 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
||||
10 | |||||
11 | /** |
||||
12 | * Implements methods to the data position interface using repositories |
||||
13 | */ |
||||
0 ignored issues
–
show
|
|||||
14 | trait DataPositionTrait |
||||
15 | { |
||||
16 | |||||
17 | /** |
||||
18 | * Get the position using the data position |
||||
19 | * |
||||
20 | * @return Position|null |
||||
21 | */ |
||||
22 | 2 | public function position(): ?Position |
|||
23 | { |
||||
24 | try { |
||||
25 | 2 | return app(\BristolSU\ControlDB\Contracts\Repositories\Position::class)->getByDataProviderId($this->id()); |
|||
0 ignored issues
–
show
It seems like
id() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
26 | 1 | } catch (ModelNotFoundException $e) { |
|||
27 | 1 | return null; |
|||
28 | } |
||||
29 | } |
||||
30 | |||||
31 | /** |
||||
32 | * Set the position name |
||||
33 | * |
||||
34 | * @param string|null $name |
||||
0 ignored issues
–
show
|
|||||
35 | */ |
||||
0 ignored issues
–
show
|
|||||
36 | 2 | public function setName(?string $name): void |
|||
37 | { |
||||
38 | 2 | app(DataPosition::class)->update($this->id(), $name, $this->description()); |
|||
0 ignored issues
–
show
It seems like
description() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
39 | 2 | } |
|||
40 | |||||
41 | /** |
||||
42 | * Set the description |
||||
43 | * |
||||
44 | * @param string|null $description |
||||
0 ignored issues
–
show
|
|||||
45 | */ |
||||
0 ignored issues
–
show
|
|||||
46 | 2 | public function setDescription(?string $description): void |
|||
47 | { |
||||
48 | 2 | app(DataPosition::class)->update($this->id(), $this->name(), $description); |
|||
0 ignored issues
–
show
It seems like
name() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
49 | |||||
50 | } |
||||
51 | } |