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

LaraCache::laraCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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