ProfileJsonResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 27
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 16 5
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