Passed
Push — master ( 2173e1...800b2f )
by Mostafa
05:03 queued 02:26
created

LaraCache::updateCacheEntity()   C

Complexity

Conditions 15
Paths 24

Size

Total Lines 43
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
c 1
b 0
f 0
dl 0
loc 43
rs 5.9166
cc 15
nc 24
nop 3

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Mostafaznv\LaraCache\Traits;
4
5
use Exception;
6
use Mostafaznv\LaraCache\Cache;
7
use Mostafaznv\LaraCache\CacheEntity;
8
use Mostafaznv\LaraCache\Observers\LaraCacheObserver;
9
10
/**
11
 * @mixin \Illuminate\Database\Eloquent\Model
12
 */
13
trait LaraCache
14
{
15
    public static bool $isEnabled = true;
16
17
    /**
18
     * Boot LaraCache
19
     *
20
     * @throws Exception
21
     */
22
    public static function bootLaraCache()
23
    {
24
        self::observe(LaraCacheObserver::class);
25
    }
26
27
    /**
28
     * Get the entities should store in cache
29
     *
30
     * @return CacheEntity[]
31
     */
32
    abstract static public function cacheEntities(): array;
33
34
    public static function cache(): Cache
35
    {
36
        return new Cache(self::class);
37
    }
38
39
    public static function laraCache(): Cache
40
    {
41
        return new Cache(self::class);
42
    }
43
}
44