Completed
Pull Request — master (#75)
by
unknown
01:12
created

CouldNotSendNotification   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A serviceRespondedWithAnError() 0 8 1
A invalidToken() 0 4 1
A invalidMessage() 0 4 1
1
<?php
2
3
namespace NotificationChannels\Fcm\Exceptions;
4
5
use Exception;
6
use Kreait\Firebase\Exception\MessagingException;
7
use Kreait\Firebase\Messaging\Message;
8
9
class CouldNotSendNotification extends Exception
10
{
11
    public static function serviceRespondedWithAnError(MessagingException $exception)
12
    {
13
        return new static(
14
            $exception->getMessage(),
15
            $exception->getCode(),
16
            $exception
17
        );
18
    }
19
20
    public static function invalidToken()
21
    {
22
        return new static('The notifiable did not have a fcm token.');
23
    }
24
25
    public static function invalidMessage()
26
    {
27
        return new static('The toFcm() method only accepts instances of ' . Message::class);
28
    }
29
}
30