CouldNotSendNotification   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 49
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidCredentials() 0 4 1
A invalidReceiver() 0 4 1
A missingFrom() 0 4 1
A missingNotifyUrl() 0 4 1
A invalidMessageObject() 0 10 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