AwsPinpointChannel::send()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 9.7998
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 12
1
<?php
2
3
namespace NotificationChannels\AwsPinpoint;
4
5
use Illuminate\Notifications\Notification;
6
7
class AwsPinpointChannel
8
{
9
    /**
10
     * @var \NotificationChannels\AwsPinpoint\AwsPinpointClient
11
     */
12
    protected $client;
13
14
    /**
15
     * Create a AwsPinpointChannel instance.
16
     *
17
     * @param \NotificationChannels\AwsPinpoint\AwsPinpointClient $client
18
     */
19
    public function __construct(AwsPinpointClient $client)
20
    {
21
        $this->client = $client;
22
    }
23
24
    /**
25
     * Send the given notification.
26
     *
27
     * @param mixed $notifiable
28
     * @param \Illuminate\Notifications\Notification $notification
29
     */
30
    public function send($notifiable, Notification $notification)
31
    {
32
        $message = $notification->toAwsPinpoint($notifiable);
0 ignored issues
show
Bug introduced by
The method toAwsPinpoint() does not seem to exist on object<Illuminate\Notifications\Notification>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
34
        if (is_string($message)) {
35
            $message = AwsPinpointSmsMessage::create($message);
36
        }
37
38
        if ($to = $notifiable->routeNotificationFor('awspinpoint')) {
39
            $message->setRecipients($to);
40
        }
41
42
        $this->client->send($message);
43
    }
44
}
45