JWTServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 20 3
1
<?php
2
3
namespace Bludata\Lumen\Authentication\JWT\Providers;
4
5
use Exception;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\ServiceProvider;
8
9
class JWTServiceProvider extends ServiceProvider
10
{
11
    public function register()
12
    {
13
        $this->app->bind('Bludata\Lumen\Authentication\JWT\Interfaces\JWTInterface', 'Bludata\Lumen\Authentication\JWT\Libs\JWT');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 130 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
14
15
        $this->app['auth']->viaRequest(
16
            'api', function ($request) {
17
                if ($token = $request->header('authorization')) {
18
                    $auth = app('Bludata\Lumen\Authentication\JWT\Interfaces\AuthRepositoryInterface');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 103 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
19
20
                    try {
21
                        $user = $auth->getUserLoggedByToken($token);
22
                    } catch (Exception $e) {
23
                        abort(401, $e->getMessage());
24
                    }
25
26
                    return $user;
27
                }
28
            }
29
        );
30
    }
31
}
32