Passed
Push — master ( 71d0aa...52238f )
by Andrés
04:41
created

HablameChannel::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Andreshg112\HablameSms;
4
5
use Illuminate\Notifications\Notification;
6
use Andreshg112\HablameSms\Exceptions\CouldNotSendNotification;
7
8
class HablameChannel
9
{
10
    /**
11
     * Send the given notification.
12
     *
13
     * @param mixed $notifiable
14
     * @param \Illuminate\Notifications\Notification $notification
15
     *
16
     * @throws \Andreshg112\HablameSms\Exceptions\CouldNotSendNotification
17
     */
18 2
    public function send($notifiable, Notification $notification)
19
    {
20
        /** @var \Andreshg112\HablameSms\HablameMessage $message */
21 2
        $message = $notification->toHablameNotification($notifiable);
0 ignored issues
show
Bug introduced by
The method toHablameNotification() 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...
22
23 2
        $message = $message->toArray();
24
25 2
        $response = Facade::sendMessage(
26 2
            $message['numero'],
27 2
            $message['sms'],
28 2
            $message['fecha'],
29 2
            $message['referencia']
30
        );
31
32 2
        if ($response['resultado'] !== 0) {
33 1
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
34
        }
35 1
    }
36
}
37