Completed
Push — master ( 54527b...d7d176 )
by Richan
01:11
created

CacheableTrait::cacheDuration()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Suitmedia\Cacheable\Traits\Model;
4
5
use Suitmedia\Cacheable\CacheableObserver;
6
7
trait CacheableTrait
8
{
9
    /**
10
     * Boot the Cacheable trait by attaching
11
     * a new observer to the current model.
12
     *
13
     * @return void
14
     */
15
    public static function bootCacheableTrait()
16
    {
17
        static::observe(app(CacheableObserver::class));
18
    }
19
20
    /**
21
     * Generate cache tags automatically
22
     * based on the model class name.
23
     *
24
     * @return string|array
25
     */
26
    public function cacheTags()
27
    {
28
        if (property_exists($this, 'cacheTags')) {
29
            return (array) static::$cacheTags;
30
        }
31
32
        return class_basename(get_class($this));
33
    }
34
}
35