Passed
Push — master ( 685c75...93fbb7 )
by Biao
14:29 queued 10:37
created

PrometheusMiddleware::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
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
7
class PrometheusMiddleware
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class PrometheusMiddleware
Loading history...
8
{
9
    private $prometheusExporter;
0 ignored issues
show
Coding Style introduced by
Private member variable "prometheusExporter" must be prefixed with an underscore
Loading history...
10
11
    public function __construct(PrometheusExporter $prometheusExporter)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
12
    {
13
        $this->prometheusExporter = $prometheusExporter;
14
    }
15
16
    /**
17
     * Handle an incoming request.
18
     *
19
     * @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...
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...
Coding Style introduced by
Missing parameter comment
Loading history...
20
     * @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
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 17 spaces after parameter type; 1 found
Loading history...
21
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
22
     */
23
    public function handle($request, Closure $next)
24
    {
25
        $response = $next($request);
26
        try {
27
            $this->prometheusExporter->observeRequest($request, $response);
28
        } catch (\Exception $e) {
29
            app('log')->error('PrometheusMiddleware: failed to observe request', ['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

29
            /** @scrutinizer ignore-call */ 
30
            app('log')->error('PrometheusMiddleware: failed to observe request', ['exception' => $e]);
Loading history...
30
        } finally {
31
            return $response;
32
        }
33
    }
34
}
35