1 | <?php |
||
2 | namespace BeyondCode\QueryDetector\Outputs; |
||
3 | |||
4 | use Illuminate\Support\Collection; |
||
5 | use Symfony\Component\HttpFoundation\Response; |
||
6 | use Illuminate\Http\JsonResponse; |
||
7 | |||
8 | class Json implements Output |
||
9 | { |
||
10 | public function boot() |
||
11 | { |
||
12 | // |
||
13 | } |
||
14 | |||
15 | public function output(Collection $detectedQueries, Response $response) |
||
16 | { |
||
17 | if ($response instanceof JsonResponse) { |
||
18 | $data = $response->getData(true); |
||
19 | if (! is_array($data)){ |
||
20 | $data = [ $data ]; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
21 | } |
||
22 | |||
23 | $data['warning_queries'] = $detectedQueries; |
||
24 | $response->setData($data); |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 |