Completed
Push — master ( 6db363...e3ebaa )
by Michel
11s
created

CmsmsChannel::send()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 2
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
namespace NotificationChannels\Cmsms;
6
7
use Illuminate\Notifications\Notification;
8
9
class CmsmsChannel
10
{
11
    /** @var CmsmsClient */
12
    protected $client;
13
14
    /**
15
     * @param CmsmsClient $client
16
     */
17 1
    public function __construct(CmsmsClient $client)
18
    {
19 1
        $this->client = $client;
20 1
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     *
28
     * @throws \NotificationChannels\Cmsms\Exceptions\CouldNotSendNotification
29
     */
30
    public function send($notifiable, Notification $notification)
31
    {
32
        if (! $recipient = $notifiable->routeNotificationFor('Cmsms')) {
33
            return;
34
        }
35
36
        $message = $notification->toCmsms($notifiable);
0 ignored issues
show
Bug introduced by
The method toCmsms() 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...
37
38
        if (is_string($message)) {
39
            $message = CmsmsMessage::create($message);
40
        }
41
42
        $this->client->send($message, $recipient);
43
    }
44
}
45