Skip to content

Commit df19be9

Browse files
committed
fix: all methods in ResponseTrait should be protected
Public methods can be accessible via HTTP.
1 parent 9e9dfbb commit df19be9

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

system/API/ResponseTrait.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ trait ResponseTrait
8787
*
8888
* @return mixed
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;
@@ -121,7 +121,7 @@ public function respond($data = null, ?int $status = null, string $message = '')
121121
*
122122
* @return mixed
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];
@@ -147,7 +147,7 @@ public function fail($messages, int $status = 400, ?string $code = null, string
147147
*
148148
* @return mixed
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
}
@@ -159,7 +159,7 @@ public function respondCreated($data = null, string $message = '')
159159
*
160160
* @return mixed
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
}
@@ -171,7 +171,7 @@ public function respondDeleted($data = null, string $message = '')
171171
*
172172
* @return mixed
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
}
@@ -182,7 +182,7 @@ public function respondUpdated($data = null, string $message = '')
182182
*
183183
* @return mixed
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
}
@@ -194,7 +194,7 @@ public function respondNoContent(string $message = 'No Content')
194194
*
195195
* @return mixed
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
}
@@ -205,7 +205,7 @@ public function failUnauthorized(string $description = 'Unauthorized', ?string $
205205
*
206206
* @return mixed
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
}
@@ -215,7 +215,7 @@ public function failForbidden(string $description = 'Forbidden', ?string $code =
215215
*
216216
* @return mixed
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
}
@@ -227,7 +227,7 @@ public function failNotFound(string $description = 'Not Found', ?string $code =
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
}
@@ -239,7 +239,7 @@ public function failValidationError(string $description = 'Bad Request', ?string
239239
*
240240
* @return mixed
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
}
@@ -249,7 +249,7 @@ public function failValidationErrors($errors, ?string $code = null, string $mess
249249
*
250250
* @return mixed
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
}
@@ -261,7 +261,7 @@ public function failResourceExists(string $description = 'Conflict', ?string $co
261261
*
262262
* @return mixed
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
}
@@ -271,7 +271,7 @@ public function failResourceGone(string $description = 'Gone', ?string $code = n
271271
*
272272
* @return mixed
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

Comments
 (0)