@@ -27,6 +27,7 @@ public function __construct(
2727 if ($ exception instanceof LaravelApiProblemException) {
2828 $ this ->apiProblemException = $ exception ;
2929 $ this ->apiProblemException ();
30+
3031 return ;
3132 }
3233 match (get_class ($ exception )) {
@@ -40,8 +41,6 @@ public function __construct(
4041
4142 /**
4243 * Render the exception as an HTTP response.
43- *
44- * @return JsonResponse
4544 */
4645 public function render (): JsonResponse
4746 {
@@ -56,8 +55,6 @@ public function render(): JsonResponse
5655
5756 /**
5857 * Debug the class in array to view more details, such as: api problem and exception
59- *
60- * @return array
6158 */
6259 public function toDebuggableArray (): array
6360 {
@@ -82,8 +79,6 @@ public function toDebuggableArray(): array
8279
8380 /**
8481 * Transform any exception into an http api problem with status code
85- *
86- * @param null|int $statusCode
8782 */
8883 protected function default (?int $ statusCode = null ): void
8984 {
@@ -105,7 +100,7 @@ protected function validation(): void
105100 $ extensions = [
106101 'errors ' => ($ this ->exception instanceof ValidationException)
107102 ? $ this ->exception ->errors ()
108- : null
103+ : null ,
109104 ];
110105 $ this ->apiProblem = new LaravelHttpApiProblem (
111106 Response::HTTP_UNPROCESSABLE_ENTITY ,
@@ -132,8 +127,6 @@ protected function apiProblemException(): void
132127
133128 /**
134129 * Get uri as instance
135- *
136- * @return string
137130 */
138131 protected function getUriInstance (): string
139132 {
@@ -142,30 +135,25 @@ protected function getUriInstance(): string
142135
143136 /**
144137 * Get the context if it exists within the exception and return it as an extension
145- *
146- * @return array
147138 */
148139 protected function getContextExceptionAsExtensions (): array
149140 {
150141 $ extensions = [];
151- if (!method_exists ($ this ->exception , 'context ' )) {
142+ if (! method_exists ($ this ->exception , 'context ' )) {
152143 return $ extensions ;
153144 }
154145 $ context = $ this ->exception ->context ();
155146 if (is_array ($ context )) {
156147 $ extensions = $ context ;
157- } elseif (!empty ($ context )) {
148+ } elseif (! empty ($ context )) {
158149 $ extensions = [$ context ];
159150 }
151+
160152 return $ extensions ;
161153 }
162154
163155 /**
164156 * Gets the status code from the exception code, or from the HttpException Interface, otherwise it returns an Internal Server Error
165- *
166- * @param null|int $code
167- *
168- * @return int
169157 */
170158 protected function getStatusCode (?int $ code ): int
171159 {
@@ -177,17 +165,14 @@ protected function getStatusCode(?int $code): int
177165 ? $ this ->exception ->getStatusCode ()
178166 : Response::HTTP_INTERNAL_SERVER_ERROR ;
179167 }
168+
180169 return ($ this ->isStatusCodeInternalOrServerError ($ this ->exception ->getCode ()))
181170 ? $ this ->exception ->getCode ()
182171 : Response::HTTP_INTERNAL_SERVER_ERROR ;
183172 }
184173
185174 /**
186175 * Checks if the status code is of the integer type and is in the range of Client and Server Errors
187- *
188- * @param null|int $statusCode
189- *
190- * @return bool
191176 */
192177 protected function isStatusCodeInternalOrServerError (?int $ statusCode ): bool
193178 {
@@ -196,10 +181,6 @@ protected function isStatusCodeInternalOrServerError(?int $statusCode): bool
196181
197182 /**
198183 * Serialize the exception into an array
199- *
200- * @param \Throwable $throwable
201- *
202- * @return array
203184 */
204185 private function serializeException (\Throwable $ throwable ): array
205186 {
0 commit comments