Total Complexity | 3 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 77.78% |
Changes | 0 |
1 | <?php |
||
17 | class ApiException extends Exception |
||
18 | { |
||
19 | public const DEFAULT_MESSAGE = 'General error.'; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $type; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $data; |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | * |
||
34 | * @param string $message |
||
35 | * @param array $data |
||
36 | */ |
||
37 | 4 | public function __construct(string $message, int $code, array $data = []) |
|
43 | 4 | } |
|
44 | |||
45 | /** |
||
46 | * @param array $data |
||
47 | * |
||
48 | * @return ApiException |
||
49 | */ |
||
50 | public static function createWithData(array $data = []): self |
||
51 | { |
||
52 | return new static(static::DEFAULT_MESSAGE, 0, $data); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return array |
||
57 | */ |
||
58 | 3 | public function getData(): array |
|
59 | { |
||
60 | 3 | return $this->data; |
|
61 | } |
||
63 |