cybercog /
laravel-eloquent-flag
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /* |
||||||
| 4 | * This file is part of Laravel Eloquent Flag. |
||||||
| 5 | * |
||||||
| 6 | * (c) Anton Komarev <[email protected]> |
||||||
| 7 | * |
||||||
| 8 | * For the full copyright and license information, please view the LICENSE |
||||||
| 9 | * file that was distributed with this source code. |
||||||
| 10 | */ |
||||||
| 11 | |||||||
| 12 | declare(strict_types=1); |
||||||
| 13 | |||||||
| 14 | namespace Cog\Flag\Traits\Classic; |
||||||
| 15 | |||||||
| 16 | trait HasActiveFlagHelpers |
||||||
| 17 | { |
||||||
| 18 | public function initializeHasActiveFlagHelpers(): void |
||||||
| 19 | { |
||||||
| 20 | $this->casts['is_active'] = 'boolean'; |
||||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||||
| 21 | } |
||||||
| 22 | |||||||
| 23 | public function isActivated(): bool |
||||||
| 24 | { |
||||||
| 25 | return $this->getAttributeValue('is_active'); |
||||||
|
0 ignored issues
–
show
It seems like
getAttributeValue() 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 | public function isNotActivated(): bool |
||||||
| 29 | { |
||||||
| 30 | return !$this->isActivated(); |
||||||
| 31 | } |
||||||
| 32 | |||||||
| 33 | public function activate(): void |
||||||
| 34 | { |
||||||
| 35 | $this->setAttribute('is_active', true); |
||||||
|
0 ignored issues
–
show
It seems like
setAttribute() 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 | $this->save(); |
||||||
|
0 ignored issues
–
show
It seems like
save() 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...
|
|||||||
| 37 | |||||||
| 38 | $this->fireModelEvent('activated', false); |
||||||
|
0 ignored issues
–
show
It seems like
fireModelEvent() 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...
|
|||||||
| 39 | } |
||||||
| 40 | |||||||
| 41 | public function undoActivate(): void |
||||||
| 42 | { |
||||||
| 43 | $this->setAttribute('is_active', false); |
||||||
| 44 | $this->save(); |
||||||
| 45 | |||||||
| 46 | $this->fireModelEvent('activatedUndone', false); |
||||||
| 47 | } |
||||||
| 48 | } |
||||||
| 49 |