BaseClient::getNotificationClass()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Skater4\LaravelSentryNotifications\Services\Messengers\Clients\Base;
4
5
use Illuminate\Notifications\Notification;
6
use Skater4\LaravelSentryNotifications\Notifications\Factories\NotificationEntityFactory;
7
use Skater4\LaravelSentryNotifications\Notifications\Factories\NotificationFactory;
8
use Skater4\LaravelSentryNotifications\Notifications\Interfaces\NotifableEntityInterface;
9
use Skater4\LaravelSentryNotifications\Services\Messengers\Factories\MessageFormatterFactory;
10
use Skater4\LaravelSentryNotifications\Services\Messengers\Interfaces\MessageFormatterInterface;
11
12
abstract class BaseClient
13
{
14
    protected $service;
15
    protected $messageFormatter;
16
    protected $notifableEntity;
17
    protected $notificationClass;
18
19
    protected function getMessageFormatter(): MessageFormatterInterface
20
    {
21
        if (!$this->messageFormatter) {
22
            $this->messageFormatter = app(MessageFormatterFactory::class)->create();
23
        }
24
25
        return $this->messageFormatter;
26
    }
27
28
    protected function getNotifableEntity(): NotifableEntityInterface
29
    {
30
        if (!$this->notifableEntity) {
31
            $this->notifableEntity = app(NotificationEntityFactory::class)->create();
32
        }
33
34
        return $this->notifableEntity;
35
    }
36
37
    protected function getNotificationClass(): Notification
38
    {
39
        if (!$this->notificationClass) {
40
            $this->notificationClass = app(NotificationFactory::class)->create();
41
        }
42
43
        return $this->notificationClass;
44
    }
45
}
46