Total Complexity | 4 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | abstract class AbstractResponse |
||
8 | { |
||
9 | /** |
||
10 | * The HTTP status code. |
||
11 | * |
||
12 | * @var int |
||
13 | */ |
||
14 | protected $status; |
||
15 | |||
16 | /** |
||
17 | * The errors on response. |
||
18 | * |
||
19 | * @var \SMartins\Exceptions\Response\ErrorHandledCollectionInterface |
||
20 | */ |
||
21 | protected $errors; |
||
22 | |||
23 | /** |
||
24 | * Create new Response response passing the errors. |
||
25 | * |
||
26 | * @param \SMartins\Exceptions\Response\ErrorHandledCollectionInterface $errors |
||
27 | */ |
||
28 | public function __construct(ErrorHandledCollectionInterface $errors) |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Get the HTTP status code. |
||
37 | * |
||
38 | * @return int |
||
39 | */ |
||
40 | public function getStatus() |
||
41 | { |
||
42 | return $this->status; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Set the HTTP status code. |
||
47 | * |
||
48 | * @param int $status The HTTP status code. |
||
49 | * |
||
50 | * @return self |
||
51 | */ |
||
52 | public function setStatus(int $status) |
||
53 | { |
||
54 | $this->status = $status; |
||
55 | |||
56 | return $this; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Get the errors on response. |
||
61 | * |
||
62 | * @return \SMartins\Exceptions\Response\ErrorHandledCollectionInterface |
||
63 | */ |
||
64 | public function getErrors() |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Returns JSON response. |
||
71 | * |
||
72 | * @return \Illuminate\Http\JsonResponse |
||
73 | */ |
||
74 | abstract public function json(): JsonResponse; |
||
75 | } |
||
76 |