CouldNotSendNotification::invalidMessageObject()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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