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\DataPosition as DataPositionModel; |
||||
8 | use BristolSU\ControlDB\Contracts\Repositories\DataPosition as DataPositionRepository; |
||||
9 | use BristolSU\ControlDB\Contracts\Repositories\Pivots\Tags\PositionPositionTag; |
||||
10 | use BristolSU\ControlDB\Contracts\Repositories\Position; |
||||
11 | use Illuminate\Support\Collection; |
||||
12 | |||||
13 | /** |
||||
14 | * Implements common methods using repositories required by the position model interface |
||||
15 | */ |
||||
0 ignored issues
–
show
|
|||||
16 | trait PositionTrait |
||||
17 | { |
||||
18 | |||||
19 | /** |
||||
20 | * Get the data model for this position |
||||
21 | * |
||||
22 | * @return DataPositionModel |
||||
23 | */ |
||||
24 | 11 | public function data(): DataPositionModel |
|||
25 | { |
||||
26 | 11 | return app(DataPositionRepository::class)->getById($this->dataProviderId()); |
|||
0 ignored issues
–
show
It seems like
dataProviderId() 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
![]() |
|||||
27 | } |
||||
28 | |||||
29 | /** |
||||
30 | * Set the ID of the data provider |
||||
31 | * |
||||
32 | * @param int $dataProviderId |
||||
0 ignored issues
–
show
|
|||||
33 | */ |
||||
0 ignored issues
–
show
|
|||||
34 | 2 | public function setDataProviderId(int $dataProviderId): void |
|||
35 | { |
||||
36 | 2 | app(Position::class)->update($this->id(), $dataProviderId); |
|||
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
![]() |
|||||
37 | 2 | } |
|||
38 | |||||
39 | /** |
||||
40 | * Roles with this position |
||||
41 | * |
||||
42 | * @return Collection |
||||
43 | */ |
||||
44 | 3 | public function roles(): Collection |
|||
45 | { |
||||
46 | 3 | return app(\BristolSU\ControlDB\Contracts\Repositories\Role::class)->allThroughPosition($this); |
|||
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\PositionTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Position expected by parameter $position of BristolSU\ControlDB\Cont...e::allThroughPosition() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
47 | } |
||||
48 | |||||
49 | /** |
||||
50 | * Tags the position is tagged with |
||||
51 | * |
||||
52 | * @return Collection |
||||
53 | */ |
||||
54 | 2 | public function tags(): Collection |
|||
55 | { |
||||
56 | 2 | return app(PositionPositionTag::class)->getTagsThroughPosition($this); |
|||
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\PositionTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Position expected by parameter $position of BristolSU\ControlDB\Cont...etTagsThroughPosition() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
57 | } |
||||
58 | |||||
59 | /** |
||||
60 | * Add a tag to the position |
||||
61 | * |
||||
62 | * @param \BristolSU\ControlDB\Contracts\Models\Tags\PositionTag $positionTag |
||||
0 ignored issues
–
show
|
|||||
63 | */ |
||||
0 ignored issues
–
show
|
|||||
64 | 6 | public function addTag(\BristolSU\ControlDB\Contracts\Models\Tags\PositionTag $positionTag): void |
|||
65 | { |
||||
66 | 6 | app(PositionPositionTag::class)->addTagToPosition($positionTag, $this); |
|||
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\PositionTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Position expected by parameter $position of BristolSU\ControlDB\Cont...Tag::addTagToPosition() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
67 | 6 | } |
|||
68 | |||||
69 | /** |
||||
70 | * Remove a tag from the position |
||||
71 | * |
||||
72 | * @param \BristolSU\ControlDB\Contracts\Models\Tags\PositionTag $positionTag |
||||
0 ignored issues
–
show
|
|||||
73 | */ |
||||
0 ignored issues
–
show
|
|||||
74 | 2 | public function removeTag(\BristolSU\ControlDB\Contracts\Models\Tags\PositionTag $positionTag): void |
|||
75 | { |
||||
76 | 2 | app(PositionPositionTag::class)->removeTagFromPosition($positionTag, $this); |
|||
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\PositionTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Position expected by parameter $position of BristolSU\ControlDB\Cont...removeTagFromPosition() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
77 | 2 | } |
|||
78 | |||||
79 | } |