Passed
Push — master ( 9234be...3143c1 )
by Arthur
20:30
created

CacheObserver::updated()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
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 ignore-type  annotation

21
        $model::cache()->store(/** @scrutinizer ignore-type */ $model);
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
Bug introduced by
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 ignore-type  annotation

29
        $model::cache()->store(/** @scrutinizer ignore-type */ $model);
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
Bug introduced by
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 ignore-call  annotation

37
        $model::cache()->remove($model->/** @scrutinizer ignore-call */ getKey());
Loading history...
38
    }
39
}
40