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

CmsmsChannel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 81.82%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 36
ccs 9
cts 11
cp 0.8182
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 14 3
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