Completed
Pull Request — master (#9)
by
unknown
02:22
created

DeleteHost   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 14 2
1
<?php
2
3
namespace Spatie\ServerMonitor\Commands;
4
5
use Spatie\ServerMonitor\Models\Host;
6
7
class DeleteHost extends BaseCommand
8
{
9
    protected $signature = 'server-monitor:delete-host
10
                            {name : The host\'s name}';
11
12
    protected $description = 'Delete a host';
13
14
    public function handle()
15
    {
16
        $name = $this->argument('name');
17
18
        $host = Host::where('name', $name)->first();
19
20
        if(! $host) {
21
            return $this->error("Host with name '{$name}' not found.");
22
        }
23
24
        $host->delete();
25
26
        $this->info("{$name} deleted!");
27
    }
28
}
29