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 = []) |
||
72 | |||
73 | /** |
||
74 | * Return json response with error. |
||
75 | * |
||
76 | * @param \Throwable $exception |
||
77 | * @param string|array $status |
||
78 | * @param array $attributes |
||
79 | * @param array $options |
||
80 | * @return \Illuminate\Http\JsonResponse |
||
81 | */ |
||
82 | public function error($exception, $status = null, array $attributes = [], array $options = []) |
||
88 | |||
89 | /** |
||
90 | * Retrieve/Set json response status. |
||
91 | * |
||
92 | * @param string $status |
||
93 | * @return \ArinaSystems\JsonResponse\Status|self |
||
94 | */ |
||
95 | public function status(string $status = null) |
||
104 | |||
105 | /** |
||
106 | * Retrieve/Set json response options. |
||
107 | * |
||
108 | * @param string|array|null $key |
||
109 | * @param mixed|null $default |
||
110 | * @return \ArinaSystems\JsonResponse\Option|mixed |
||
111 | */ |
||
112 | public function options($key = null, $default = null) |
||
124 | |||
125 | /** |
||
126 | * Retrieve/Set json response attributes. |
||
127 | * |
||
128 | * @param string|array|null $key |
||
129 | * @param mixed|null $default |
||
130 | * @return \ArinaSystems\JsonResponse\Attribute|mixed |
||
131 | */ |
||
132 | public function attributes($key = null, $default = null) |
||
144 | |||
145 | /** |
||
146 | * Set json response options. |
||
147 | * |
||
148 | * @param \ArinaSystems\JsonResponse\Option|array|string $options |
||
149 | * @param null|mixed $value |
||
150 | * @return self |
||
151 | */ |
||
152 | public function setOptions($options, $value = null) |
||
162 | |||
163 | /** |
||
164 | * Set json response attributes. |
||
165 | * |
||
166 | * @param \ArinaSystems\JsonResponse\Attribute|array|string $attributes |
||
167 | * @param null|mixed $value |
||
168 | * @return self |
||
169 | */ |
||
170 | public function setAttributes($attributes, $value = null) |
||
179 | |||
180 | /** |
||
181 | * Get the json response data array. |
||
182 | * |
||
183 | * @param bool $error |
||
184 | * @return array |
||
185 | */ |
||
186 | protected function build(bool $error = false): array |
||
198 | |||
199 | /** |
||
200 | * Get response data structure. |
||
201 | * |
||
202 | * @param bool $error |
||
203 | * @return array |
||
204 | */ |
||
205 | public function structure(bool $error = false): array |
||
215 | |||
216 | /** |
||
217 | * Get the current instance of json response builder. |
||
218 | * |
||
219 | * @return ArinaSystems\JsonResponse\JsonResponse |
||
220 | */ |
||
221 | public function instance(): self |
||
225 | } |
||
226 |
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.