File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 77use ApiSkeletons \Laravel \ApiProblem \Exception \InvalidArgumentException ;
88use ApiSkeletons \Laravel \ApiProblem \Exception \ProblemExceptionInterface ;
99use Exception ;
10+ use Illuminate \Http \Response ;
1011use Throwable ;
1112
1213use function array_key_exists ;
1718use function get_class ;
1819use function in_array ;
1920use function is_numeric ;
21+ use function response ;
2022use function sprintf ;
2123use function strtolower ;
2224use function trim ;
@@ -213,6 +215,16 @@ public function toArray(): array
213215 return array_merge ($ this ->additionalDetails , $ problem );
214216 }
215217
218+ /**
219+ * Compose a response and return it.
220+ */
221+ public function response (): Response
222+ {
223+ return response ()
224+ ->setStatusCode ($ this ->getStatus ())
225+ ->setContent ($ this ->toArray ());
226+ }
227+
216228 /**
217229 * Set the flag indicating whether an exception detail should include a
218230 * stack trace and previous exception information.
You can’t perform that action at this time.
0 commit comments