BaseClient   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 14
c 1
b 0
f 0
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessageFormatter() 0 7 2
A getNotificationClass() 0 7 2
A getNotifableEntity() 0 7 2
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