Passed
Push — master ( ebde88...d0f1c0 )
by Stephen
13:30 queued 10:34
created

HasAutoCacheKey   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A cacheKey() 0 15 4
1
<?php
2
3
namespace Sfneal\Caching\Traits;
4
5
trait HasAutoCacheKey
6
{
7
    use IsCacheable;
8
9
    /**
10
     * Retrieve the Query cache key.
11
     *
12
     * @return string
13
     */
14
    public function cacheKey(): string
15
    {
16
        $reflection = (new \ReflectionClass($this));
17
18
        $key = 'auto_'.strtolower(str_replace('\\', '-', $reflection->getName()));
19
20
        if (count($reflection->getProperties())) {
21
            foreach ($reflection->getProperties() as $property) {
22
                if ($property->getName() != 'ttl') {
23
                    $key .= ':'.$this->{$property->getName()};
24
                }
25
            }
26
        }
27
28
        return $key;
29
    }
30
}
31