Total Complexity | 6 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class RestException extends \RuntimeException |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $path; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $params; |
||
28 | |||
29 | /** |
||
30 | * @var ResponseInterface|null |
||
31 | */ |
||
32 | private $response; |
||
33 | |||
34 | /** |
||
35 | * @var RequestInterface|null |
||
36 | */ |
||
37 | private $request; |
||
38 | |||
39 | public function __construct( |
||
40 | string $message, |
||
41 | string $path, |
||
42 | array $params = [], |
||
43 | int $code = 0, |
||
44 | ?Exception $previous = null |
||
45 | ) { |
||
46 | parent::__construct($message, $code, $previous); |
||
47 | $this->path = $path; |
||
48 | $this->params = $params; |
||
49 | if ($previous instanceof RequestException) { |
||
50 | $this->response = $previous->getResponse(); |
||
51 | $this->request = $previous->getRequest(); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | public function getPath(): string |
||
56 | { |
||
57 | return $this->path; |
||
58 | } |
||
59 | |||
60 | public function getParams(): array |
||
61 | { |
||
62 | return $this->params; |
||
63 | } |
||
64 | |||
65 | public function getResponse(): ?ResponseInterface |
||
66 | { |
||
67 | return $this->response; |
||
68 | } |
||
69 | |||
70 | public function getRequest(): ?RequestInterface |
||
73 | } |
||
74 | } |
||
75 |