Passed
Push — master ( 9e5a11...b08ede )
by frey
01:13 queued 11s
created

FingerprintMiddleware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 7
c 1
b 0
f 1
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 2
1
<?php
2
3
namespace Freyo\ApiGateway;
4
5
use Closure;
6
use Freyo\ApiGateway\Kernel\Traits\WithFingerprint;
7
8
class FingerprintMiddleware
9
{
10
    use WithFingerprint;
11
12
    /**
13
     * Handle an incoming request.
14
     *
15
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
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...
16
     * @param  \Closure  $next
17
     * @return mixed
18
     */
19
    public function handle($request, Closure $next)
20
    {
21
        if ($this->fingerprint($request->all()) !== $request->header('fingerprint')) {
22
            return response()->json([
0 ignored issues
show
Bug introduced by
The function response 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

22
            return /** @scrutinizer ignore-call */ response()->json([
Loading history...
23
                'message' => 'fingerprint does not match',
24
            ], 401);
25
        }
26
27
        return $next($request);
28
    }
29
}