HablameChannel::send()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 9
c 3
b 1
f 0
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 9.9666
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Andreshg112\HablameSms;
4
5
use Andreshg112\HablameSms\Exceptions\CouldNotSendNotification;
6
7
class HablameChannel
8
{
9
    /**
10
     * Send the given notification.
11
     *
12
     * @param  \Illuminate\Notifications\Notifiable  $notifiable
13
     * @throws \Andreshg112\HablameSms\Exceptions\CouldNotSendNotification
14
     */
15
    public function send($notifiable, HablameNotification $notification)
16
    {
17
        $message = $notification->toHablameNotification($notifiable);
18 4
19
        /** @var \Andreshg112\HablameSms\HablameMessage $message */
20
        $messageArray = $message->toArray();
21
22
        try {
23 4
            Facade::sendMessage(
24
                $messageArray['phoneNumbers'],
25 4
                $messageArray['sms'],
26
                $messageArray['sendDate']
27 4
            );
28 4
        } catch (\Throwable $th) {
29 4
            throw new CouldNotSendNotification($th->getMessage(), $th->getCode(), $th);
30 4
        }
31 4
    }
32
}
33