JWTServiceProvider::register()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 1
nop 0
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
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