RouteRegistrar::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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