ApiException   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 141
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 0
dl 0
loc 141
ccs 21
cts 27
cp 0.7778
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 2
A getErrorCode() 0 4 1
A getStatusCode() 0 4 1
A setProperties() 0 5 1
A getProperties() 0 4 1
A setData() 0 5 1
A getData() 0 4 1
A getViolations() 0 4 1
A setViolations() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\Bundle\ApiBundle\Exception;
5
6
use Exception;
7
use Paysera\Bundle\ApiBundle\Entity\Violation;
8
9
class ApiException extends Exception
10
{
11
    const INVALID_REQUEST = 'invalid_request';
12
    const INVALID_PARAMETERS = 'invalid_parameters';
13
    const INVALID_STATE = 'invalid_state';
14
    const INVALID_GRANT = 'invalid_grant';
15
    const INVALID_CODE = 'invalid_code';
16
    const UNAUTHORIZED = 'unauthorized';
17
    const FORBIDDEN = 'forbidden';
18
    const NOT_FOUND = 'not_found';
19
    const RATE_LIMIT_EXCEEDED = 'rate_limit_exceeded';
20
    const INTERNAL_SERVER_ERROR = 'internal_server_error';
21
    const NOT_ACCEPTABLE = 'not_acceptable';
22
    const OFFSET_TOO_LARGE = 'offset_too_large';
23
    const INVALID_CURSOR = 'invalid_cursor';
24
25
    /**
26
     * @var string
27
     */
28
    private $errorCode;
29
30
    /**
31
     * @var int|null
32
     */
33
    private $statusCode;
34
35
    /**
36
     * @var array|null
37
     */
38
    private $properties;
39
40
    /**
41
     * @var array|null
42
     */
43
    private $data;
44
45
    /**
46
     * @var Violation[]
47
     */
48
    private $violations;
49
50
    /**
51
     * @param string $errorCode
52
     * @param string|null $message
53
     * @param int|null $statusCode
54
     * @param Exception|null $previous
55
     * @param array|null $properties
56
     * @param array|null $data
57
     * @param array $violations
58
     */
59 41
    public function __construct(
60
        $errorCode,
61
        $message = null,
62
        $statusCode = null,
63
        Exception $previous = null,
64
        $properties = null,
65
        $data = null,
66
        array $violations = []
67
    ) {
68 41
        parent::__construct($message ?: '', 0, $previous);
69
70 41
        $this->errorCode = $errorCode;
71 41
        $this->statusCode = $statusCode;
72 41
        $this->properties = $properties;
73 41
        $this->data = $data;
74 41
        $this->violations = $violations;
75 41
    }
76
77
    /**
78
     * @return string
79
     */
80 30
    public function getErrorCode()
81
    {
82 30
        return $this->errorCode;
83
    }
84
85
    /**
86
     * @return int|null
87
     */
88 30
    public function getStatusCode()
89
    {
90 30
        return $this->statusCode;
91
    }
92
93
    /**
94
     * @param array|null $properties
95
     *
96
     * @return $this
97
     */
98
    public function setProperties($properties)
99
    {
100
        $this->properties = $properties;
101
        return $this;
102
    }
103
104
    /**
105
     * @return array|null
106
     */
107 30
    public function getProperties()
108
    {
109 30
        return $this->properties;
110
    }
111
112
    /**
113
     * @param array|null $data
114
     *
115
     * @return $this
116
     */
117
    public function setData($data)
118
    {
119
        $this->data = $data;
120
        return $this;
121
    }
122
123
    /**
124
     * @return array|null
125
     */
126 30
    public function getData()
127
    {
128 30
        return $this->data;
129
    }
130
131
    /**
132
     * @return Violation[]
133
     */
134 30
    public function getViolations()
135
    {
136 30
        return $this->violations;
137
    }
138
139
    /**
140
     * @param Violation[] $violations
141
     *
142
     * @return $this
143
     */
144 19
    public function setViolations($violations)
145
    {
146 19
        $this->violations = $violations;
147 19
        return $this;
148
    }
149
}
150