Passed
Push — master ( 86cfdb...e29dd4 )
by nguereza
03:59 queued 01:47
created

UserServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 1
A addRoutes() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Platine\App\Provider;
6
7
use Platine\App\Http\Action\Permission\PermissionAction;
8
use Platine\App\Http\Action\Role\RoleAction;
9
use Platine\App\Http\Action\User\AuthAction;
10
use Platine\App\Http\Action\User\LogoutAction;
11
use Platine\Framework\Service\ServiceProvider;
12
use Platine\Route\Router;
13
14
/**
15
* @class UserServiceProvider
16
* @package Platine\App\Provider
17
*/
18
class UserServiceProvider extends ServiceProvider
19
{
20
    /**
21
    * {@inheritdoc}
22
    */
23
    public function register(): void
24
    {
25
        // User
26
        $this->app->bind(AuthAction::class);
27
        $this->app->bind(LogoutAction::class);
28
29
        // Permission
30
        $this->app->bind(PermissionAction::class);
31
32
        // Role
33
        $this->app->bind(RoleAction::class);
34
    }
35
36
37
    /**
38
    * {@inheritdoc}
39
    */
40
    public function addRoutes(Router $router): void
41
    {
42
        $router->group('/user', function (Router $router) {
43
            $router->add('/login', AuthAction::class, ['GET', 'POST'], 'user_login');
44
            $router->get('/logout', LogoutAction::class, 'user_logout');
45
        });
46
47
        $router->resource('/permission', PermissionAction::class, 'permission');
48
        $router->resource('/role', RoleAction::class, 'role');
49
    }
50
}
51