Test Failed
Pull Request — master (#1)
by
unknown
05:13
created

AfricasTalkingChannel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 15
c 2
b 1
f 0
dl 0
loc 35
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 17 3
A __construct() 0 3 1
1
<?php
2
3
namespace NotificationChannels\AfricasTalking;
4
5
use AfricasTalking\SDK\AfricasTalking as AfricasTalkingSDK;
6
use Exception;
7
use Illuminate\Notifications\Notifiable;
8
use Illuminate\Notifications\Notification;
9
use NotificationChannels\AfricasTalking\Exceptions\CouldNotSendNotification;
10
11
class AfricasTalkingChannel
12
{
13
    /** @var AfricasTalkingSDK */
14
    protected $africasTalking;
15
16
    /** @param AfricasTalkingSDK $africasTalking */
17
    public function __construct(AfricasTalkingSDK $africasTalking)
18
    {
19
        $this->africasTalking = $africasTalking;
20
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     * @throws CouldNotSendNotification
28
     */
29
    public function send($notifiable, Notification $notification)
30
    {
31
        $message = $notification->toAfricasTalking($notifiable);
0 ignored issues
show
Bug introduced by
The method toAfricasTalking() does not exist on Illuminate\Notifications\Notification. It seems like you code against a sub-type of Illuminate\Notifications\Notification such as NotificationChannels\Afr...g\Test\TestNotification. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        /** @scrutinizer ignore-call */ 
32
        $message = $notification->toAfricasTalking($notifiable);
Loading history...
32
        $driver = $notifiable->routeNotificationFor('africasTalking');
33
34
        $phoneNumber = $driver
35
            ? $driver
36
            : $notifiable->phone_number;
37
38
        try {
39
            $this->africasTalking->send([
0 ignored issues
show
Bug introduced by
The method send() does not exist on AfricasTalking\SDK\AfricasTalking. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
            $this->africasTalking->/** @scrutinizer ignore-call */ 
40
                                   send([

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...
40
                'to' => $phoneNumber,
41
                'message' => $message->getContent(),
42
                'from' => $message->getSender()
43
            ]);
44
        } catch (Exception $e) {
45
            throw CouldNotSendNotification::serviceRespondedWithAnError($e->getMessage());
46
        }
47
    }
48
}
49