Json::output()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 10
rs 10
cc 3
nc 3
nop 2
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