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

SetWebhook::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
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
use Illuminate\Support\Facades\Log;
9
10
class SetWebhook extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'tg-notifier:webhook:set';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Set webhook';
25
26
    protected WebhookService $webhookService;
27
28
    public function __construct(WebhookService $webhookService)
29
    {
30
        parent::__construct();
31
        $this->webhookService = $webhookService;
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return void
38
     */
39
    public function handle(): void
40
    {
41
        try {
42
            $log = $this->webhookService->handle();
43
44
            $this->info($log);
45
        } catch (WebhookException $e) {
46
            $this->error($e->getMessage());
47
        }
48
    }
49
}
50