WebhookAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getUpdates() 0 3 1
A __construct() 0 5 1
A set() 0 3 1
A delete() 0 3 1
1
<?php
2
3
namespace CSlant\TelegramGitNotifierApp\Http\Actions;
4
5
use CSlant\TelegramGitNotifier\Exceptions\WebhookException;
6
use CSlant\TelegramGitNotifier\Webhook;
7
8
class WebhookAction
9
{
10
    protected string $token;
11
12
    protected Webhook $webhook;
13
14
    public function __construct()
15
    {
16
        $this->webhook = new Webhook();
17
        $this->webhook->setToken(config('telegram-git-notifier.bot.token'));
18
        $this->webhook->setUrl(config('telegram-git-notifier.app.url'));
19
    }
20
21
    /**
22
     * Set webhook for telegram bot
23
     *
24
     * @return string
25
     * @throws WebhookException
26
     */
27
    public function set(): string
28
    {
29
        return $this->webhook->setWebhook();
30
    }
31
32
    /**
33
     * Delete webhook for telegram bot
34
     *
35
     * @return string
36
     * @throws WebhookException
37
     */
38
    public function delete(): string
39
    {
40
        return $this->webhook->deleteWebHook();
41
    }
42
43
    /**
44
     * Get webhook update
45
     *
46
     * @return string
47
     * @throws WebhookException
48
     */
49
    public function getUpdates(): string
50
    {
51
        return $this->webhook->getUpdates();
52
    }
53
}
54