Passed
Push — master ( cb14e2...009e7e )
by Keoghan
03:39
created

Domain   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 39
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 18 2
1
<?php
2
3
namespace App\Commands;
4
5
use App\Models\Setting;
6
use App\Support\Dnsmasq\Config;
7
8
class Domain extends BaseCommand
9
{
10
    /**
11
     * The signature of the command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'domain {domain?}';
16
17
    /**
18
     * The description of the command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Set the domain for Porter sites';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return void
28
     */
29 2
    public function handle(): void
30
    {
31 2
        $domain = $this->argument('domain');
32
33 2
        if (!$domain) {
34 1
            $this->info(sprintf("The current domain is '%s'", setting('domain')));
35
36 1
            return;
37
        }
38
39 1
        $old = setting('domain');
40
41 1
        Setting::where('name', 'domain')->first()->update(['value' => $domain]);
42
43 1
        app()->make(Config::class)->updateDomain($old, $domain);
44
45 1
        $this->call('site:renew-certs');
46 1
        $this->call('make-files');
47 1
    }
48
}
49