CouldNotSendNotification   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A serviceRespondedWithAnError() 0 12 3
1
<?php
2
3
namespace NotificationChannels\Pushover\Exceptions;
4
5
use Exception;
6
use Psr\Http\Message\ResponseInterface;
7
8
class CouldNotSendNotification extends Exception
9
{
10 2
    public static function serviceRespondedWithAnError(ResponseInterface $response)
11
    {
12 2
        $statusCode = $response->getStatusCode();
13
14 2
        $result = json_decode($response->getBody());
15
16 2
        if ($result && isset($result->errors)) {
17 1
            return new static('Pushover responded with an error ('.$statusCode.'): '.implode(', ', $result->errors));
18
        }
19
20 1
        return new static('Pushover responded with an error ('.$statusCode.').');
21
    }
22
}
23