bristol-su /
control
| 1 | <?php |
||||
| 2 | |||||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||
| 3 | namespace BristolSU\ControlDB\Traits; |
||||
| 4 | |||||
| 5 | use BristolSU\ControlDB\Contracts\Models\DataGroup; |
||||
| 6 | use BristolSU\ControlDB\Contracts\Repositories\Group; |
||||
| 7 | use BristolSU\ControlDB\Contracts\Repositories\Pivots\Tags\GroupGroupTag; |
||||
| 8 | use BristolSU\ControlDB\Contracts\Repositories\Pivots\UserGroup; |
||||
| 9 | use BristolSU\ControlDB\Contracts\Repositories\Role; |
||||
| 10 | use Illuminate\Support\Collection; |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * Implements common methods using repositories required by the group model interface |
||||
| 14 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 15 | trait GroupTrait |
||||
| 16 | { |
||||
| 17 | |||||
| 18 | /** |
||||
| 19 | * Get the data group for this group |
||||
| 20 | * |
||||
| 21 | * @return DataGroup |
||||
| 22 | */ |
||||
| 23 | 13 | public function data(): DataGroup |
|||
| 24 | { |
||||
| 25 | 13 | return app(\BristolSU\ControlDB\Contracts\Repositories\DataGroup::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
Loading history...
|
|||||
| 26 | } |
||||
| 27 | |||||
| 28 | /** |
||||
| 29 | * Set the ID of the data provider |
||||
| 30 | * |
||||
| 31 | * @param int $dataProviderId |
||||
|
0 ignored issues
–
show
|
|||||
| 32 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 33 | 2 | public function setDataProviderId(int $dataProviderId): void |
|||
| 34 | { |
||||
| 35 | 2 | app(Group::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
Loading history...
|
|||||
| 36 | 2 | } |
|||
| 37 | |||||
| 38 | /** |
||||
| 39 | * Members of the group |
||||
| 40 | * |
||||
| 41 | * @return Collection |
||||
| 42 | */ |
||||
| 43 | 2 | public function members(): Collection |
|||
| 44 | { |
||||
| 45 | 2 | return app(UserGroup::class)->getUsersThroughGroup($this); |
|||
|
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\GroupTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Group expected by parameter $group of BristolSU\ControlDB\Cont...:getUsersThroughGroup().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 46 | } |
||||
| 47 | |||||
| 48 | /** |
||||
| 49 | * Roles belonging to the group |
||||
| 50 | * |
||||
| 51 | * @return Collection |
||||
| 52 | */ |
||||
| 53 | 3 | public function roles(): Collection |
|||
| 54 | { |
||||
| 55 | 3 | return app(Role::class)->allThroughGroup($this); |
|||
|
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\GroupTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Group expected by parameter $group of BristolSU\ControlDB\Cont...Role::allThroughGroup().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 56 | } |
||||
| 57 | |||||
| 58 | /** |
||||
| 59 | * Tags the group is tagged with |
||||
| 60 | * |
||||
| 61 | * @return Collection |
||||
| 62 | */ |
||||
| 63 | 2 | public function tags(): Collection |
|||
| 64 | { |
||||
| 65 | 2 | return app(GroupGroupTag::class)->getTagsThroughGroup($this); |
|||
|
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\GroupTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Group expected by parameter $group of BristolSU\ControlDB\Cont...::getTagsThroughGroup().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 66 | } |
||||
| 67 | |||||
| 68 | /** |
||||
| 69 | * Add a tag to the group |
||||
| 70 | * |
||||
| 71 | * @param \BristolSU\ControlDB\Contracts\Models\Tags\GroupTag $groupTag |
||||
|
0 ignored issues
–
show
|
|||||
| 72 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 73 | 6 | public function addTag(\BristolSU\ControlDB\Contracts\Models\Tags\GroupTag $groupTag): void |
|||
| 74 | { |
||||
| 75 | 6 | app(GroupGroupTag::class)->addTagToGroup($groupTag, $this); |
|||
|
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\GroupTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Group expected by parameter $group of BristolSU\ControlDB\Cont...oupTag::addTagToGroup().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 76 | 6 | } |
|||
| 77 | |||||
| 78 | /** |
||||
| 79 | * Remove a tag from the group |
||||
| 80 | * |
||||
| 81 | * @param \BristolSU\ControlDB\Contracts\Models\Tags\GroupTag $groupTag |
||||
|
0 ignored issues
–
show
|
|||||
| 82 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 83 | 2 | public function removeTag(\BristolSU\ControlDB\Contracts\Models\Tags\GroupTag $groupTag): void |
|||
| 84 | { |
||||
| 85 | 2 | app(GroupGroupTag::class)->removeTagFromGroup($groupTag, $this); |
|||
|
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\GroupTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Group expected by parameter $group of BristolSU\ControlDB\Cont...g::removeTagFromGroup().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 86 | 2 | } |
|||
| 87 | |||||
| 88 | /** |
||||
| 89 | * Add a user to the group |
||||
| 90 | * |
||||
| 91 | * @param \BristolSU\ControlDB\Contracts\Models\User $user |
||||
|
0 ignored issues
–
show
|
|||||
| 92 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 93 | 5 | public function addUser(\BristolSU\ControlDB\Contracts\Models\User $user): void |
|||
| 94 | { |
||||
| 95 | 5 | app(UserGroup::class)->addUserToGroup($user, $this); |
|||
|
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\GroupTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Group expected by parameter $group of BristolSU\ControlDB\Cont...Group::addUserToGroup().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 96 | |||||
| 97 | 5 | } |
|||
| 98 | |||||
| 99 | /** |
||||
| 100 | * Remove a user from the group |
||||
| 101 | * |
||||
| 102 | * @param \BristolSU\ControlDB\Contracts\Models\User $user |
||||
|
0 ignored issues
–
show
|
|||||
| 103 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 104 | 2 | public function removeUser(\BristolSU\ControlDB\Contracts\Models\User $user): void |
|||
| 105 | { |
||||
| 106 | 2 | app(UserGroup::class)->removeUserFromGroup($user, $this); |
|||
|
0 ignored issues
–
show
$this of type BristolSU\ControlDB\Traits\GroupTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Group expected by parameter $group of BristolSU\ControlDB\Cont...::removeUserFromGroup().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 107 | 2 | } |
|||
| 108 | |||||
| 109 | |||||
| 110 | } |