Completed
Push — master ( 0cdd35...cbf418 )
by Rafael
03:53 queued 02:54
created

CouldNotSendNotification   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 39
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidMessageObject() 0 8 2
A invalidReceiver() 0 6 1
A notificationMethodNotExists() 0 7 2
1
<?php
2
3
namespace NotificationChannels\TotalVoice\Exceptions;
4
5
use NotificationChannels\TotalVoice\TotalVoiceMessage;
6
use NotificationChannels\TotalVoice\TotalVoiceAudioMessage;
7
8
class CouldNotSendNotification extends \Exception
9
{
10
    /**
11
     * @param mixed $message
12
     *
13
     * @return static
14
     */
15 1
    public static function invalidMessageObject($message)
16
    {
17 1
        $className = get_class($message) ?: 'Unknown';
18
19 1
        return new static(
20 1
            "Notification was not sent. Message object class `{$className}` is invalid. It should
21 1
            be either `".TotalVoiceMessage::class.'` or `'.TotalVoiceAudioMessage::class.'`');
22
    }
23
24
    /**
25
     * @return static
26
     */
27 1
    public static function invalidReceiver()
28
    {
29 1
        return new static(
30
            'The notifiable did not have a receiving phone number. Add a routeNotificationForTotalVoice
31 1
            method or a phone_number attribute to your notifiable.');
32
    }
33
34
    /**
35
     * @param mixed $notification
36
     *
37
     * @return static
38
     */
39 6
    public static function notificationMethodNotExists($notification)
40
    {
41 6
        $className = get_class($notification) ?: 'Unknown';
42
43 6
        return new static(
44 6
            "Notification was not sent. Method toTotalVoice() not exists on `{$className} notification class`.");
45
    }
46
}
47