DeleteHost   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 18 3
1
<?php
2
3
namespace Spatie\ServerMonitor\Commands;
4
5
class DeleteHost extends BaseCommand
6
{
7
    protected $signature = 'server-monitor:delete-host
8
                            {name : The name of the host to be deleted}';
9
10
    protected $description = 'Delete a host';
11
12
    public function handle()
13
    {
14
        $name = $this->argument('name');
15
16
        $host = $this->determineHostModelClass()::where('name', $name)->first();
0 ignored issues
show
Bug introduced by
The method where cannot be called on $this->determineHostModelClass() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
17
18
        if (! $host) {
19
            return $this->error("Host with name `{$name}` not found.");
20
        }
21
22
        if (! $this->confirm("Are you sure you wish to delete `{$name}`?")) {
23
            return;
24
        }
25
26
        $host->delete();
27
28
        $this->info("Host `{$name}` was deleted!");
29
    }
30
}
31