1 | <?php |
||
9 | class JsonResponse |
||
10 | { |
||
11 | /** |
||
12 | * @var \ArinaSystems\JsonResponse\Status |
||
13 | */ |
||
14 | protected $status; |
||
15 | |||
16 | /** |
||
17 | * @var \ArinaSystems\JsonResponse\Option |
||
18 | */ |
||
19 | protected $options; |
||
20 | |||
21 | /** |
||
22 | * @var \ArinaSystems\JsonResponse\Attribute |
||
23 | */ |
||
24 | protected $attributes; |
||
25 | |||
26 | /** |
||
27 | * Create a new instance. |
||
28 | * |
||
29 | * @param \ArinaSystems\JsonResponse\Option|array|string $options |
||
30 | * @return void |
||
|
|||
31 | */ |
||
32 | public function __construct(Option $options, Attribute $attributes, Status $status) |
||
38 | |||
39 | /** |
||
40 | * Return json response. |
||
41 | * |
||
42 | * @param string|array $status |
||
43 | * @param array $attributes |
||
44 | * @param array $options |
||
45 | * @return \Illuminate\Http\JsonResponse |
||
46 | */ |
||
47 | public function json($status = null, array $attributes = [], array $options = []) |
||
74 | |||
75 | /** |
||
76 | * Return json response with error. |
||
77 | * |
||
78 | * @param \Throwable $exception |
||
79 | * @param string|array $status |
||
80 | * @param array $attributes |
||
81 | * @param array $options |
||
82 | * @return \Illuminate\Http\JsonResponse |
||
83 | */ |
||
84 | public function error($exception, $status = null, array $attributes = [], array $options = []) |
||
90 | |||
91 | /** |
||
92 | * Retrieve/Set json response status. |
||
93 | * |
||
94 | * @param string $status |
||
95 | * @return \ArinaSystems\JsonResponse\Status|self |
||
96 | */ |
||
97 | public function status(string $status = null) |
||
106 | |||
107 | /** |
||
108 | * Retrieve/Set json response options. |
||
109 | * |
||
110 | * @param string|array|null $key |
||
111 | * @param mixed|null $default |
||
112 | * @return \ArinaSystems\JsonResponse\Option|mixed |
||
113 | */ |
||
114 | public function options($key = null, $default = null) |
||
126 | |||
127 | /** |
||
128 | * Retrieve/Set json response attributes. |
||
129 | * |
||
130 | * @param string|array|null $key |
||
131 | * @param mixed|null $default |
||
132 | * @return \ArinaSystems\JsonResponse\Attribute|mixed |
||
133 | */ |
||
134 | public function attributes($key = null, $default = null) |
||
146 | |||
147 | /** |
||
148 | * Set json response options. |
||
149 | * |
||
150 | * @param \ArinaSystems\JsonResponse\Option|array|string $options |
||
151 | * @param null|mixed $value |
||
152 | * @return self |
||
153 | */ |
||
154 | public function setOptions($options, $value = null) |
||
164 | |||
165 | /** |
||
166 | * Set json response attributes. |
||
167 | * |
||
168 | * @param \ArinaSystems\JsonResponse\Attribute|array|string $attributes |
||
169 | * @param null|mixed $value |
||
170 | * @return self |
||
171 | */ |
||
172 | public function setAttributes($attributes, $value = null) |
||
181 | |||
182 | /** |
||
183 | * Get the json response data array. |
||
184 | * |
||
185 | * @param bool $error |
||
186 | * @return array |
||
187 | */ |
||
188 | protected function build(bool $error = false): array |
||
200 | |||
201 | /** |
||
202 | * Get response data structure. |
||
203 | * |
||
204 | * @param bool $error |
||
205 | * @return array |
||
206 | */ |
||
207 | public function structure(bool $error = false): array |
||
217 | |||
218 | /** |
||
219 | * Get the current instance of json response builder. |
||
220 | * |
||
221 | * @return ArinaSystems\JsonResponse\JsonResponse |
||
222 | */ |
||
223 | public function instance(): self |
||
227 | } |
||
228 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.