Completed
Push — dev ( 51f83b...f650a7 )
by Amr
03:27
created

SettingObserver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 0
cbo 0
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteCache() 0 8 2
A updated() 0 4 1
A deleted() 0 4 1
1
<?php
2
3
namespace Merodiro\Settings\Observers;
4
5
use Illuminate\Support\Facades\Cache;
6
use Merodiro\Settings\Models\Setting;
7
8
class SettingObserver
9
{
10
11 16
    private function deleteCache(Setting $setting)
12
    {
13 16
        $suffix = $setting->owner_id ? $setting->owner_id: 'global';
14
15 16
        $cache_key = config('settings.cache_prefix') . $setting->key . '_' . $suffix;
16
17 16
        Cache::forget($cache_key);
18 16
    }
19
20 8
    public function updated(Setting $setting)
21
    {
22 8
        $this->deleteCache($setting);
23 8
    }
24
25 8
    public function deleted(Setting $setting)
26
    {
27 8
        $this->deleteCache($setting);
28 8
    }
29
}
30