WebhookService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 6
Bugs 2 Features 0
Metric Value
wmc 5
eloc 9
c 6
b 2
f 0
dl 0
loc 57
rs 10

5 Methods

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