CouldNotSendNotification::invalidReceiver()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace NotificationChannels\Infobip\Exceptions;
4
5
use NotificationChannels\Infobip\InfobipMessage;
6
use NotificationChannels\Infobip\InfobipSmsAdvancedMessage;
7
8
class CouldNotSendNotification extends \Exception
9
{
10
    /**
11
     * @return static
12
     */
13
    public static function invalidCredentials()
14
    {
15
        return new static('Invalid credentials');
16
    }
17
18
    /**
19
     * @return static
20
     */
21
    public static function invalidReceiver()
22
    {
23
        return new static('The notifiable did not have a phone number. Add routeNotificationForInfoBip to your notifiable');
24
    }
25
26
    /**
27
     * @return static
28
     */
29
    public static function missingFrom()
30
    {
31
        return new static('Notification was not sent. Missing `from` number.');
32
    }
33
34
    /**
35
     * @return static
36
     */
37
    public static function missingNotifyUrl()
38
    {
39
        return new static('Notification was not sent. Missing `notify_url`');
40
    }
41
42
    /**
43
     * @param $message
44
     * @return static
45
     */
46
    public static function invalidMessageObject($message)
47
    {
48
        $className = get_class($message) ?: 'Unknown';
49
50
        return new static(
51
            'Notification was not sent. Message object class '.$className.
52
            ' is invalid. It should be either '.InfobipMessage::class.
53
            ' or '.InfobipSmsAdvancedMessage::class
54
        );
55
    }
56
}
57