deviouspk /
larapi
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Created by PhpStorm. |
||||
| 4 | * User: arthur |
||||
| 5 | * Date: 11.10.18 |
||||
| 6 | * Time: 13:31. |
||||
| 7 | */ |
||||
| 8 | |||||
| 9 | namespace Foundation\Observers; |
||||
| 10 | |||||
| 11 | use Foundation\Abstracts\Observers\Observer; |
||||
| 12 | use Foundation\Traits\Cacheable; |
||||
| 13 | |||||
| 14 | class CacheObserver extends Observer |
||||
| 15 | { |
||||
| 16 | /** |
||||
| 17 | * @param Cacheable | \Eloquent $model |
||||
| 18 | */ |
||||
| 19 | 1 | public function created($model) |
|||
| 20 | { |
||||
| 21 | 1 | $model::cache()->store($model); |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 22 | 1 | } |
|||
| 23 | |||||
| 24 | /** |
||||
| 25 | * @param Cacheable | \Eloquent $model |
||||
| 26 | */ |
||||
| 27 | public function updated($model) |
||||
| 28 | { |
||||
| 29 | $model::cache()->store($model); |
||||
|
0 ignored issues
–
show
It seems like
$model can also be of type Foundation\Traits\Cacheable; however, parameter $model of Foundation\Cache\ModelCache::store() does only seem to accept Eloquent, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 30 | } |
||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * @param Cacheable | \Eloquent $model |
||||
| 34 | */ |
||||
| 35 | public function deleted($model) |
||||
| 36 | { |
||||
| 37 | $model::cache()->remove($model->getKey()); |
||||
|
0 ignored issues
–
show
It seems like
getKey() 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...
|
|||||
| 38 | } |
||||
| 39 | } |
||||
| 40 |