SetHost   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
dl 0
loc 34
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 2
1
<?php
2
3
namespace App\Commands\Dns;
4
5
use App\Commands\BaseCommand;
6
use App\Support\Dnsmasq\Config;
7
8
class SetHost extends BaseCommand
9
{
10
    /**
11
     * The signature of the command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'dns:set-host {--restore}';
16
17
    /**
18
     * The description of the command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Set the host based on the OS';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return void
28
     */
29 4
    public function handle(): void
30
    {
31 4
        if ($this->option('restore')) {
32 2
            $this->porterLibrary->getMechanic()->removeAlternativeLoopbackAddress();
33 2
            app(Config::class)->updateIp($this->porterLibrary->getMechanic()->getStandardLoopback());
34 2
            $this->porter->restart('dns');
35
36 2
            return;
37
        }
38
39 2
        $this->porterLibrary->getMechanic()->addAlternativeLoopbackAddress();
40 2
        app(Config::class)->updateIp($this->porterLibrary->getMechanic()->getAlternativeLoopback());
41 2
        $this->porter->restart('dns');
42
    }
43
}
44