ClientException::internalServerError()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenlyst\BaseCommerce;
6
7
use Exception;
8
9
class ClientException extends Exception
10
{
11
    public const INVALID_CREDENTIALS = 'Invalid Credentials';
12
    public const INVALID_URL_OR_HOST_OFFLINE = 'Invalid URL or Host is offline';
13
    public const INTERNAL_SERVER_ERROR = 'Internal Server Error. Please contact tech support.';
14
    public const ERROR_CONNECTING_TO_ENVIRONMENT = 'Error Connecting to BaseCommerce';
15
16
    /**
17
     * @return ClientException
18
     */
19
    public static function invalidCredentials(): self
20
    {
21
        return new static(self::INVALID_CREDENTIALS, 403);
22
    }
23
24
    /**
25
     * @return ClientException
26
     */
27
    public static function internalServerError(): self
28
    {
29
        return new static(self::INTERNAL_SERVER_ERROR, 500);
30
    }
31
32
    /**
33
     * @return ClientException
34
     */
35
    public static function invalidURLOrHost(): self
36
    {
37
        return new static(self::INVALID_URL_OR_HOST_OFFLINE, 404);
38
    }
39
40
    /**
41
     * @return ClientException
42
     */
43
    public static function errorConnectingToEnvironment(): self
44
    {
45
        return new static(self::ERROR_CONNECTING_TO_ENVIRONMENT, 400);
46
    }
47
48
    public static function unknownError($errorMessage): self
49
    {
50
        return new static($errorMessage);
51
    }
52
}
53