Every8dChannel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 46
ccs 0
cts 16
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 19 3
1
<?php
2
3
namespace Recca0120\Every8d;
4
5
use Illuminate\Notifications\Notification;
6
7
class Every8dChannel
8
{
9
    /**
10
     * $client.
11
     *
12
     * @var \Recca0120\Every8d\Client
13
     */
14
    protected $client;
15
16
    /**
17
     * __construct.
18
     *
19
     * @param \Recca0120\Every8d\Client $client
20
     */
21
    public function __construct(Client $client)
22
    {
23
        $this->client = $client;
24
    }
25
26
    /**
27
     * Send the given notification.
28
     *
29
     * @param mixed $notifiable
30
     * @param \Illuminate\Notifications\Notification $notification
31
     * @return \Recca0120\Every8d\Every8dMessage
32
     */
33
    public function send($notifiable, Notification $notification)
34
    {
35
        if (! $to = $notifiable->routeNotificationFor('every8d')) {
36
            return;
37
        }
38
39
        $message = $notification->toEvery8d($notifiable);
40
41
        if (is_string($message)) {
42
            $message = new Every8dMessage($message);
43
        }
44
45
        return $this->client->send([
46
            'subject' => $message->subject,
47
            'to' => $to,
48
            'text' => trim($message->content),
49
            'sendTime' => $message->sendTime,
50
        ]);
51
    }
52
}
53