SettingsModuleSeeder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 52
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B run() 0 24 3
1
<?php namespace Anomaly\SettingsModule;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
4
use Anomaly\Streams\Platform\Application\Command\ReadEnvironmentFile;
5
use Anomaly\Streams\Platform\Application\Command\WriteEnvironmentFile;
6
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
7
use Illuminate\Foundation\Bus\DispatchesJobs;
8
9
/**
10
 * Class SettingsModuleSeeder
11
 *
12
 * @link          http://pyrocms.com/
13
 * @author        PyroCMS, Inc. <[email protected]>
14
 * @author        Ryan Thompson <[email protected]>
15
 */
16
class SettingsModuleSeeder extends Seeder
17
{
18
19
    use DispatchesJobs;
20
21
    /**
22
     * The settings repository.
23
     *
24
     * @var SettingRepositoryInterface
25
     */
26
    protected $settings;
27
28
    /**
29
     * Create a new SettingsModuleSeeder instance.
30
     *
31
     * @param SettingRepositoryInterface $settings
32
     */
33
    public function __construct(SettingRepositoryInterface $settings)
34
    {
35
        parent::__construct();
36
37
        $this->settings = $settings;
38
    }
39
40
    /**
41
     * Run the command.
42
     */
43
    public function run()
44
    {
45
        $data = $this->dispatch(new ReadEnvironmentFile());
46
47
        if ($timezone = array_pull($data, 'APP_TIMEZONE')) {
48
            $this->settings->create(
49
                [
50
                    'key'   => 'streams::timezone',
51
                    'value' => $timezone,
52
                ]
53
            );
54
        }
55
56
        if ($locale = array_pull($data, 'DEFAULT_LOCALE')) {
57
            $this->settings->create(
58
                [
59
                    'key'   => 'streams::default_locale',
60
                    'value' => $locale,
61
                ]
62
            );
63
        }
64
65
        $this->dispatch(new WriteEnvironmentFile($data));
66
    }
67
}
68