Passed
Pull Request — main (#58)
by
unknown
02:27
created

SetWebhook   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 2
A __construct() 0 4 1
1
<?php
2
3
namespace CSlant\LaravelTelegramGitNotifier\Commands;
4
5
use CSlant\LaravelTelegramGitNotifier\Services\WebhookService;
6
use CSlant\TelegramGitNotifier\Exceptions\WebhookException;
7
use Illuminate\Console\Command;
8
9
class SetWebhook extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'tg-notifier:webhook:set';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Set webhook';
24
25
    protected WebhookService $webhookService;
26
27
    public function __construct(WebhookService $webhookService)
28
    {
29
        parent::__construct();
30
        $this->webhookService = $webhookService;
31
    }
32
33
    /**
34
     * Execute the console command.
35
     *
36
     * @return void
37
     */
38
    public function handle(): void
39
    {
40
        try {
41
            $log = $this->webhookService->setWebhook();
42
43
            $this->info($log);
44
        } catch (WebhookException $e) {
45
            $this->error($e->getMessage());
46
        }
47
    }
48
}
49