Completed
Push — master ( ac84c4...0288b5 )
by Pásztor
02:10
created

ServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Autumn\JWTAuth;
4
5
use Tymon\JWTAuth\JWTAuth;
6
use Tymon\JWTAuth\Middleware\RefreshToken;
7
use Tymon\JWTAuth\Middleware\GetUserFromToken;
8
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
9
10
class ServiceProvider extends IlluminateServiceProvider
11
{
12
    /**
13
     * Register the service provider.
14
     *
15
     * @return void
16
     */
17
    public function register()
18
    {
19
        $this->registerMiddleware('jwt.auth', GetUserFromToken::class);
20
        $this->registerMiddleware('jwt.refresh', RefreshToken::class);
21
    }
22
23
    public function boot()
24
    {
25
        $this->publishes([
26
            realpath(__DIR__.'/config/jwt.php') => config_path('jwt.php'),
27
            realpath(__DIR__.'/config/api.php') => config_path('api.php')
28
        ]);
29
    }
30
31
    /**
32
     * Helper method to quickly setup middleware.
33
     *
34
     * @param string $alias
35
     * @param string $class
36
     */
37
    protected function registerMiddleware($alias, $class)
38
    {
39
        $this->app['router']->middleware($alias, $class);
40
    }
41
}
42