QueryDetectorMiddleware   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 15 2
A __construct() 0 3 1
1
<?php
2
3
namespace BeyondCode\QueryDetector;
4
5
use Closure;
6
7
class QueryDetectorMiddleware
8
{
9
    /** @var QueryDetector */
10
    private $detector;
11
12
    public function __construct(QueryDetector $detector)
13
    {
14
        $this->detector = $detector;
15
    }
16
17
    /**
18
     * Handle an incoming request.
19
     *
20
     * @param  Request  $request
0 ignored issues
show
Bug introduced by
The type BeyondCode\QueryDetector\Request was not found. Did you mean Request? If so, make sure to prefix the type with \.
Loading history...
21
     * @param  Closure  $next
22
     * @return mixed
23
     */
24
    public function handle($request, Closure $next)
25
    {
26
        if (! $this->detector->isEnabled()) {
27
            return $next($request);
28
        }
29
30
        $this->detector->boot();
31
32
        /** @var \Illuminate\Http\Response $response */
33
        $response = $next($request);
34
35
        // Modify the response to add the Debugbar
36
        $this->detector->output($request, $response);
37
38
        return $response;
39
    }
40
}