DeleteExtensionPreferences   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 34
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 8 2
1
<?php namespace Anomaly\PreferencesModule\Preference\Listener;
2
3
use Anomaly\PreferencesModule\Preference\Contract\PreferenceRepositoryInterface;
4
use Anomaly\Streams\Platform\Addon\Extension\Event\ExtensionWasUninstalled;
5
6
/**
7
 * Class DeleteExtensionPreferences
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 */
13
class DeleteExtensionPreferences
14
{
15
16
    /**
17
     * The settings repository.
18
     *
19
     * @var PreferenceRepositoryInterface
20
     */
21
    protected $settings;
22
23
    /**
24
     * Create a new DeleteExtensionPreferences instance.
25
     *
26
     * @param PreferenceRepositoryInterface $settings
27
     */
28
    public function __construct(PreferenceRepositoryInterface $settings)
29
    {
30
        $this->settings = $settings;
31
    }
32
33
    /**
34
     * Handle the event.
35
     *
36
     * @param ExtensionWasUninstalled $event
37
     */
38
    public function handle(ExtensionWasUninstalled $event)
39
    {
40
        $extension = $event->getExtension();
41
42
        foreach ($this->settings->findAllByNamespace($extension->getNamespace()) as $setting) {
43
            $this->settings->delete($setting);
44
        }
45
    }
46
}
47