RouteRegistrar   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 16
c 5
b 0
f 0
dl 0
loc 56
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A all() 0 4 1
A forAuthentication() 0 11 1
A forPasswordReset() 0 7 1
1
<?php
2
3
namespace Signifly\Janitor;
4
5
use Illuminate\Contracts\Routing\Registrar as Router;
6
7
class RouteRegistrar
8
{
9
    /**
10
     * The router implementation.
11
     *
12
     * @var \Illuminate\Contracts\Routing\Registrar
13
     */
14
    protected $router;
15
16
    public function __construct(Router $router)
17
    {
18
        $this->router = $router;
19
    }
20
21
    /**
22
     * Apply all routes to the router.
23
     *
24
     * @return void
25
     */
26
    public function all()
27
    {
28
        $this->forAuthentication();
29
        $this->forPasswordReset();
30
    }
31
32
    /**
33
     * Apply authentication routes to the router.
34
     *
35
     * @return void
36
     */
37
    public function forAuthentication()
38
    {
39
        $this->router->post('login', 'AuthController@login')
40
            ->name('login');
41
42
        $this->router->post('login/refresh', 'AuthController@refresh')
43
            ->name('refresh');
44
45
        $this->router->group(['middleware' => ['auth:api']], function ($router) {
46
            $router->post('logout', 'AuthController@logout')
47
                ->name('logout');
48
        });
49
    }
50
51
    /**
52
     * Apply password reset routes to the router.
53
     *
54
     * @return void
55
     */
56
    public function forPasswordReset()
57
    {
58
        $this->router->post('password/email', 'ResetPasswordController@sendResetLinkEmail')
59
            ->name('password.email');
60
61
        $this->router->post('password/reset', 'ResetPasswordController@reset')
62
            ->name('password.reset');
63
    }
64
}
65