Completed
Push — master ( c94975...41fe5e )
by recca
02:53 queued 13s
created

Every8dChannel::send()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
ccs 12
cts 12
cp 1
rs 9.4285
cc 3
eloc 10
nc 3
nop 2
crap 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 3
    public function __construct(Client $client)
22
    {
23 3
        $this->client = $client;
24 3
    }
25
26
    /**
27
     * Send the given notification.
28
     *
29
     * @param mixed $notifiable
30
     * @param \Illuminate\Notifications\Notification $notification
31
     *
32
     * @return \Recca0120\Every8d\Every8dMessage;
0 ignored issues
show
Documentation introduced by
The doc-type \Recca0120\Every8d\Every8dMessage; could not be parsed: Expected "|" or "end of type", but got ";" at position 33. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
33
     */
34 3
    public function send($notifiable, Notification $notification)
35
    {
36 3
        if (! $to = $notifiable->routeNotificationFor('every8d')) {
37 1
            return;
38
        }
39
40 2
        $message = $notification->toEvery8d($notifiable);
41
42 2
        if (is_string($message)) {
43 1
            $message = new Every8dMessage($message);
44 1
        }
45
46 2
        return $this->client->send([
47 2
            'subject' => $message->subject,
48 2
            'to' => $to,
49 2
            'text' => trim($message->content),
50 2
        ]);
51
    }
52
}
53