DeleteWebhook   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 2
1
<?php
2
3
namespace Mpociot\CaptainHook\Commands;
4
5
use Illuminate\Console\Command;
6
use Mpociot\CaptainHook\Webhook;
7
8
class DeleteWebhook extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'hook:delete
16
                            {id : The ID of the webhook that should be deleted}';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Remove an existing webhook from the system.';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return mixed
29
     */
30
    public function handle()
31
    {
32
        $id = $this->argument('id');
33
        $hook = Webhook::find($id);
34
        if ($hook === null) {
35
            $this->error('Webhook with ID '.$id.' could not be found.');
36
        } else {
37
            $hook->delete();
38
            $this->info('The webhook was deleted successfully.');
39
        }
40
    }
41
}
42