Passed
Push — master ( 5cfb80...5d8a7b )
by CodexShaper
13:02
created

Scope   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 3
1
<?php
2
3
namespace WPB\App\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use CodexShaper\Database\Facades\Schema;
8
use CodexShaper\OAuth2\Server\Http\Requests\ServerRequest;
9
use CodexShaper\OAuth2\Server\Manager;
10
use League\OAuth2\Server\Exception\OAuthServerException;
11
use WPB\App\User;
12
13
class Scope
14
{
15
    /**
16
     * Handle an incoming request.
17
     *
18
     * @param  \Illuminate\Http\Request  $request
19
     * @param  \Closure  $next
20
     * @param  array  $scopes
21
     * @return mixed
22
     */
23
    public function handle(Request $request, Closure $next, ...$scopes)
24
    {
25
        foreach ($scopes as $scope) {
26
            if (! in_array($scope, $request->scopes)) {
27
                wp_send_json( ["msg" => "You don't have enough permission"], 400 );
0 ignored issues
show
Bug introduced by
The function wp_send_json 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

27
                /** @scrutinizer ignore-call */ 
28
                wp_send_json( ["msg" => "You don't have enough permission"], 400 );
Loading history...
28
            }
29
        }  
30
31
        return $next($request);
32
    }
33
}
34