@@ -85,9 +85,9 @@ trait ResponseTrait
8585 *
8686 * @param array|string|null $data
8787 *
88- * @return mixed
88+ * @return Response
8989 */
90- public function respond ($ data = null , ?int $ status = null , string $ message = '' )
90+ protected function respond ($ data = null , ?int $ status = null , string $ message = '' )
9191 {
9292 if ($ data === null && $ status === null ) {
9393 $ status = 404 ;
@@ -119,9 +119,9 @@ public function respond($data = null, ?int $status = null, string $message = '')
119119 * @param int $status HTTP status code
120120 * @param string|null $code Custom, API-specific, error code
121121 *
122- * @return mixed
122+ * @return Response
123123 */
124- public function fail ($ messages , int $ status = 400 , ?string $ code = null , string $ customMessage = '' )
124+ protected function fail ($ messages , int $ status = 400 , ?string $ code = null , string $ customMessage = '' )
125125 {
126126 if (! is_array ($ messages )) {
127127 $ messages = ['error ' => $ messages ];
@@ -145,9 +145,9 @@ public function fail($messages, int $status = 400, ?string $code = null, string
145145 *
146146 * @param mixed $data
147147 *
148- * @return mixed
148+ * @return Response
149149 */
150- public function respondCreated ($ data = null , string $ message = '' )
150+ protected function respondCreated ($ data = null , string $ message = '' )
151151 {
152152 return $ this ->respond ($ data , $ this ->codes ['created ' ], $ message );
153153 }
@@ -157,9 +157,9 @@ public function respondCreated($data = null, string $message = '')
157157 *
158158 * @param mixed $data
159159 *
160- * @return mixed
160+ * @return Response
161161 */
162- public function respondDeleted ($ data = null , string $ message = '' )
162+ protected function respondDeleted ($ data = null , string $ message = '' )
163163 {
164164 return $ this ->respond ($ data , $ this ->codes ['deleted ' ], $ message );
165165 }
@@ -169,9 +169,9 @@ public function respondDeleted($data = null, string $message = '')
169169 *
170170 * @param mixed $data
171171 *
172- * @return mixed
172+ * @return Response
173173 */
174- public function respondUpdated ($ data = null , string $ message = '' )
174+ protected function respondUpdated ($ data = null , string $ message = '' )
175175 {
176176 return $ this ->respond ($ data , $ this ->codes ['updated ' ], $ message );
177177 }
@@ -180,9 +180,9 @@ public function respondUpdated($data = null, string $message = '')
180180 * Used after a command has been successfully executed but there is no
181181 * meaningful reply to send back to the client.
182182 *
183- * @return mixed
183+ * @return Response
184184 */
185- public function respondNoContent (string $ message = 'No Content ' )
185+ protected function respondNoContent (string $ message = 'No Content ' )
186186 {
187187 return $ this ->respond (null , $ this ->codes ['no_content ' ], $ message );
188188 }
@@ -192,9 +192,9 @@ public function respondNoContent(string $message = 'No Content')
192192 * or had bad authorization credentials. User is encouraged to try again
193193 * with the proper information.
194194 *
195- * @return mixed
195+ * @return Response
196196 */
197- public function failUnauthorized (string $ description = 'Unauthorized ' , ?string $ code = null , string $ message = '' )
197+ protected function failUnauthorized (string $ description = 'Unauthorized ' , ?string $ code = null , string $ message = '' )
198198 {
199199 return $ this ->fail ($ description , $ this ->codes ['unauthorized ' ], $ code , $ message );
200200 }
@@ -203,31 +203,31 @@ public function failUnauthorized(string $description = 'Unauthorized', ?string $
203203 * Used when access is always denied to this resource and no amount
204204 * of trying again will help.
205205 *
206- * @return mixed
206+ * @return Response
207207 */
208- public function failForbidden (string $ description = 'Forbidden ' , ?string $ code = null , string $ message = '' )
208+ protected function failForbidden (string $ description = 'Forbidden ' , ?string $ code = null , string $ message = '' )
209209 {
210210 return $ this ->fail ($ description , $ this ->codes ['forbidden ' ], $ code , $ message );
211211 }
212212
213213 /**
214214 * Used when a specified resource cannot be found.
215215 *
216- * @return mixed
216+ * @return Response
217217 */
218- public function failNotFound (string $ description = 'Not Found ' , ?string $ code = null , string $ message = '' )
218+ protected function failNotFound (string $ description = 'Not Found ' , ?string $ code = null , string $ message = '' )
219219 {
220220 return $ this ->fail ($ description , $ this ->codes ['resource_not_found ' ], $ code , $ message );
221221 }
222222
223223 /**
224224 * Used when the data provided by the client cannot be validated.
225225 *
226- * @return mixed
226+ * @return Response
227227 *
228228 * @deprecated Use failValidationErrors instead
229229 */
230- public function failValidationError (string $ description = 'Bad Request ' , ?string $ code = null , string $ message = '' )
230+ protected function failValidationError (string $ description = 'Bad Request ' , ?string $ code = null , string $ message = '' )
231231 {
232232 return $ this ->fail ($ description , $ this ->codes ['invalid_data ' ], $ code , $ message );
233233 }
@@ -237,19 +237,19 @@ public function failValidationError(string $description = 'Bad Request', ?string
237237 *
238238 * @param string|string[] $errors
239239 *
240- * @return mixed
240+ * @return Response
241241 */
242- public function failValidationErrors ($ errors , ?string $ code = null , string $ message = '' )
242+ protected function failValidationErrors ($ errors , ?string $ code = null , string $ message = '' )
243243 {
244244 return $ this ->fail ($ errors , $ this ->codes ['invalid_data ' ], $ code , $ message );
245245 }
246246
247247 /**
248248 * Use when trying to create a new resource and it already exists.
249249 *
250- * @return mixed
250+ * @return Response
251251 */
252- public function failResourceExists (string $ description = 'Conflict ' , ?string $ code = null , string $ message = '' )
252+ protected function failResourceExists (string $ description = 'Conflict ' , ?string $ code = null , string $ message = '' )
253253 {
254254 return $ this ->fail ($ description , $ this ->codes ['resource_exists ' ], $ code , $ message );
255255 }
@@ -259,19 +259,19 @@ public function failResourceExists(string $description = 'Conflict', ?string $co
259259 * Not Found, because here we know the data previously existed, but is now gone,
260260 * where Not Found means we simply cannot find any information about it.
261261 *
262- * @return mixed
262+ * @return Response
263263 */
264- public function failResourceGone (string $ description = 'Gone ' , ?string $ code = null , string $ message = '' )
264+ protected function failResourceGone (string $ description = 'Gone ' , ?string $ code = null , string $ message = '' )
265265 {
266266 return $ this ->fail ($ description , $ this ->codes ['resource_gone ' ], $ code , $ message );
267267 }
268268
269269 /**
270270 * Used when the user has made too many requests for the resource recently.
271271 *
272- * @return mixed
272+ * @return Response
273273 */
274- public function failTooManyRequests (string $ description = 'Too Many Requests ' , ?string $ code = null , string $ message = '' )
274+ protected function failTooManyRequests (string $ description = 'Too Many Requests ' , ?string $ code = null , string $ message = '' )
275275 {
276276 return $ this ->fail ($ description , $ this ->codes ['too_many_requests ' ], $ code , $ message );
277277 }
@@ -285,7 +285,7 @@ public function failTooManyRequests(string $description = 'Too Many Requests', ?
285285 *
286286 * @return Response The value of the Response's send() method.
287287 */
288- public function failServerError (string $ description = 'Internal Server Error ' , ?string $ code = null , string $ message = '' ): Response
288+ protected function failServerError (string $ description = 'Internal Server Error ' , ?string $ code = null , string $ message = '' ): Response
289289 {
290290 return $ this ->fail ($ description , $ this ->codes ['server_error ' ], $ code , $ message );
291291 }
@@ -346,7 +346,7 @@ protected function format($data = null)
346346 *
347347 * @return $this
348348 */
349- public function setResponseFormat (?string $ format = null )
349+ protected function setResponseFormat (?string $ format = null )
350350 {
351351 $ this ->format = strtolower ($ format );
352352
0 commit comments