Completed
Push — master ( 3cb300...cba459 )
by Tobias
03:38
created

HttpServerException::serverError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Happyr\ApiClient\Exception\Domain;
4
5
use Happyr\ApiClient\Exception;
6
7
/**
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
final class HttpServerException extends \RuntimeException implements Exception
11
{
12
    public static function serverError($httpStatus = 500)
13
    {
14
        return new self('An unexpected error occurred at Happyr\'s servers. Try again later and contact support of the error sill exists.', $httpStatus);
15
    }
16
17
    public static function networkError(\Exception $previous)
18
    {
19
        return new self('Happyr\'s servers was unreachable.', 0, $previous);
20
    }
21
22
    public static function unknownHttpResponseCode($code)
23
    {
24
        return new self(sprintf('Unknown HTTP response code ("%d") received from the API server', $code));
25
    }
26
}
27