Test Failed
Pull Request — master (#68)
by Keoghan
03:05
created

SetHost   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 44.44%

Importance

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

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
use App\Support\Mechanics\Mechanic;
8
9
class SetHost extends BaseCommand
10
{
11
    /**
12
     * The signature of the command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'dns:set-host {--restore}';
17
18
    /**
19
     * The description of the command.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Set the host based on the OS';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return void
29
     */
30 1
    public function handle(): void
31
    {
32 1
        if ($this->option('restore')) {
33
            $this->porterLibrary->getMechanic()->restoreNetworking();
34
            app(Config::class)->updateIp('127.0.0.1');
35
            $this->porter->restart('dns');
36
37
            return;
38
        }
39
40 1
        $this->porterLibrary->getMechanic()->setupNetworking();
41 1
        app(Config::class)->updateIp($this->porterLibrary->getMechanic()->getHostAddress());
42
        $this->porter->restart('dns');
43
    }
44
}
45