Test Failed
Branch master (17185c)
by Keoghan
06:01 queued 02:00
created

SetHost::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

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