Json::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
c 0
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 0
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
The variable $data  does not exist. Did you maybe mean $data?
Loading history...
21
            }
22
            
23
            $data['warning_queries'] = $detectedQueries;
24
            $response->setData($data);
25
        }
26
    }
27
}
28