RequestMiddleware::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Hhxsv5\LaravelS\Components\Prometheus;
4
5
use Closure;
6
use Hhxsv5\LaravelS\Components\Prometheus\Collectors\HttpRequestCollector;
7
8
class RequestMiddleware
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class RequestMiddleware
Loading history...
9
{
10
    private $collector;
0 ignored issues
show
Coding Style introduced by
Private member variable "collector" must be prefixed with an underscore
Loading history...
11
12
    public function __construct(HttpRequestCollector $collector)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
13
    {
14
        $this->collector = $collector;
15
    }
16
17
    /**
18
     * Handle an incoming request.
19
     *
20
     * @param \Illuminate\Http\Request $request
0 ignored issues
show
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
Bug introduced by
The type Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
     * @param \Closure $next
0 ignored issues
show
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
Coding Style introduced by
Expected 17 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
22
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
23
     */
24
    public function handle($request, Closure $next)
25
    {
26
        return $next($request);
27
    }
28
29
    /**
30
     * Handle tasks after the response has been sent to the browser.
31
     *
32
     * @param \Illuminate\Http\Request $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
33
     * @param \Illuminate\Http\Response $response
0 ignored issues
show
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
Bug introduced by
The type Illuminate\Http\Response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
35
     */
36
    public function terminate($request, $response)
37
    {
38
        try {
39
            $this->collector->collect([$request, $response]);
40
        } catch (\Exception $e) {
41
            app('log')->error('PrometheusMiddleware: failed to collect request metrics.', ['exception' => $e]);
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

41
            /** @scrutinizer ignore-call */ 
42
            app('log')->error('PrometheusMiddleware: failed to collect request metrics.', ['exception' => $e]);
Loading history...
42
        }
43
    }
44
}
45