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

SetHost::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 13
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
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