ZonerSmsGatewayException   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 14.29%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 37
ccs 2
cts 14
cp 0.1429
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A unexpectedHttpStatus() 0 4 1
A usernameNotProvided() 0 4 1
A receiverNotProvided() 0 4 1
A senderNotProvided() 0 4 1
A emptyMessage() 0 4 1
A unknownZonerResponse() 0 4 1
A serviceRespondedWithAnError() 0 4 1
1
<?php
2
3
namespace NotificationChannels\ZonerSmsGateway\Exceptions;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
class ZonerSmsGatewayException extends \Exception
8
{
9 1
    public static function serviceRespondedWithAnError($code)
10
    {
11 1
        return new static("Zoner SMS-Gateway returned error code $code", $code);
12
    }
13
14
    public static function unexpectedHttpStatus(ResponseInterface $response)
15
    {
16
        return new static('Zoner SMS-Gateway returned HTTP status '.$response->getStatusCode());
17
    }
18
19
    public static function usernameNotProvided()
20
    {
21
        return new static('You must provide your Zoner SMS-Gateway username to make any API requests.');
22
    }
23
24
    public static function receiverNotProvided()
25
    {
26
        return new static('Receiver number not defined.');
27
    }
28
29
    public static function senderNotProvided()
30
    {
31
        return new static('Sender number not defined.');
32
    }
33
34
    public static function emptyMessage()
35
    {
36
        return new static('Message is empty.');
37
    }
38
39
    public static function unknownZonerResponse($response)
40
    {
41
        return new static("Zoner SMS-Gateway returned unknown response: $response");
42
    }
43
}
44