DeleteHost::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
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