Total Complexity | 4 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | trait HasSettingsRedis |
||
15 | { |
||
16 | 1 | use HasSettings; |
|
17 | |||
18 | /** |
||
19 | * @return \Glorand\Model\Settings\Contracts\SettingsManagerContract |
||
20 | * @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException |
||
21 | */ |
||
22 | 42 | public function settings(): SettingsManagerContract |
|
23 | { |
||
24 | 42 | return new RedisSettingsManager($this); |
|
25 | } |
||
26 | |||
27 | 42 | public function getSettingsValue(): array |
|
28 | { |
||
29 | 42 | $redisValue = Redis::connection()->get($this->cacheKey()); |
|
30 | 42 | $value = json_decode($redisValue, true); |
|
31 | |||
32 | 42 | return is_array($value) ? $value : []; |
|
33 | } |
||
34 | |||
35 | 42 | public function cacheKey(string $key = null): string |
|
42 | } |
||
43 | |||
44 | abstract public function getTable(); |
||
45 | |||
46 | abstract public function getKey(); |
||
47 | } |
||
48 |