Passed
Pull Request — master (#51)
by Keoghan
07:24
created

SetHost   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 34
ccs 0
cts 8
cp 0
rs 10
c 0
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
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
    public function handle(): void
31
    {
32
        $mechanic = app(Mechanic::class);
33
34
        if ($this->option('restore')) {
35
            $mechanic->restoreNetworking();
36
            app(Config::class)->updateIp('127.0.0.1');
37
38
            return;
39
        }
40
41
        $mechanic->setupNetworking();
42
        app(Config::class)->updateIp($mechanic->getHostAddress());
43
    }
44
}
45