TelegramClient::sendMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Skater4\LaravelSentryNotifications\Services\Messengers\Clients\Telegram;
4
5
use Illuminate\Support\Facades\Notification;
6
use Skater4\LaravelSentryNotifications\Enum\Services;
7
use Skater4\LaravelSentryNotifications\Services\Messengers\Interfaces\MessengerClientInterface;
8
use Skater4\LaravelSentryNotifications\Services\Messengers\Clients\Base\BaseClient;
9
use Throwable;
10
11
class TelegramClient extends BaseClient implements MessengerClientInterface
12
{
13
    protected $service = Services::SERVICE_TELEGRAM;
14
15
    public function sendMessage(Throwable $e, string $eventUrl): void
16
    {
17
        $notifableEntity = $this->getNotifableEntity();
18
        $notifableEntity->setMessage(
19
            $this->getMessageFormatter()->getExceptionMessage($e)
20
        );
21
        $notifableEntity->setEventUrl($eventUrl);
22
23
        $notificationClass = $this->getNotificationClass();
24
        Notification::sendNow($notifableEntity, $notificationClass);
25
    }
26
}
27