ProfileJsonResponse::handle()   A
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 9
nc 2
nop 2
dl 0
loc 16
ccs 0
cts 14
cp 0
crap 30
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
namespace ElfSundae\Laravel\Api\Middleware;
4
5
use Closure;
6
use Illuminate\Http\JsonResponse;
7
8
class ProfileJsonResponse
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @see https://github.com/barryvdh/laravel-debugbar/issues/252#issuecomment-248343762
14
     *
15
     * @param  \Illuminate\Http\Request  $request
16
     * @param  \Closure  $next
17
     * @return mixed
18
     */
19
    public function handle($request, Closure $next)
20
    {
21
        $response = $next($request);
22
23
        if (
24
            $response instanceof JsonResponse &&
25
            app()->bound('debugbar') &&
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            /** @scrutinizer ignore-call */ 
26
            app()->bound('debugbar') &&
Loading history...
26
            app('debugbar')->isEnabled() &&
27
            is_object($response->getData())
28
        ) {
29
            $response->setData($response->getData(true) + [
30
                '_debugbar' => app('debugbar')->getData(),
31
            ]);
32
        }
33
34
        return $response;
35
    }
36
}
37