Completed
Push — master ( b64f2f...78c033 )
by Marcel
07:21 queued 03:32
created

CmsmsChannel::send()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.1406

Importance

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