PanaceaMobileChannel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 15 3
1
<?php
2
3
namespace NotificationChannels\PanaceaMobile;
4
5
use Illuminate\Notifications\Notification;
6
7
class PanaceaMobileChannel
8
{
9
    /** @var \NotificationChannels\PanaceaMobile\PanaceaMobileApi */
10
    protected $panacea;
11
12
    public function __construct(PanaceaMobileApi $panacea)
13
    {
14
        $this->panacea = $panacea;
15
    }
16
17
    /**
18
     * Send the given notification.
19
     *
20
     * @param  mixed    $notifiable
21
     * @param  \Illuminate\Notifications\Notification  $notification
22
     *
23
     * @throws  \NotificationChannels\PanaceaMobile\Exceptions\CouldNotSendNotification
24
     */
25
    public function send($notifiable, Notification $notification)
26
    {
27
28
        if (! $to = $notifiable->routeNotificationFor('panaceamobile')) {
29
            return;
30
        }
31
32
        $message = $notification->toPanaceaMobile($notifiable);
33
34
        if (is_string($message)) {
35
            $message = new PanaceaMobileMessage($message);
36
        }
37
38
        $this->panacea->send($to, $message->toArray());
39
    }
40
}
41