Controller   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 148
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 12
lcom 0
cbo 2
dl 0
loc 148
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllPermissions() 0 6 1
A findPermission() 0 6 1
A getAllRoles() 0 6 1
A findRole() 0 6 1
A assignUserToRole() 0 6 1
A syncUserRoles() 0 6 1
A deleteRole() 0 6 1
A revokeRoleFromUser() 0 6 1
A syncPermissionOnRole() 0 6 1
A detachPermissionFromRole() 0 6 1
A attachPermissionToRole() 0 6 1
A createRole() 0 6 1
1
<?php
2
3
namespace App\Containers\Authorization\UI\API\Controllers;
4
5
use Apiato\Core\Foundation\Facades\Apiato;
6
use App\Containers\Authorization\UI\API\Requests\AssignUserToRoleRequest;
7
use App\Containers\Authorization\UI\API\Requests\AttachPermissionToRoleRequest;
8
use App\Containers\Authorization\UI\API\Requests\CreateRoleRequest;
9
use App\Containers\Authorization\UI\API\Requests\DeleteRoleRequest;
10
use App\Containers\Authorization\UI\API\Requests\DetachPermissionToRoleRequest;
11
use App\Containers\Authorization\UI\API\Requests\FindPermissionRequest;
12
use App\Containers\Authorization\UI\API\Requests\FindRoleRequest;
13
use App\Containers\Authorization\UI\API\Requests\GetAllPermissionsRequest;
14
use App\Containers\Authorization\UI\API\Requests\GetAllRolesRequest;
15
use App\Containers\Authorization\UI\API\Requests\RevokeUserFromRoleRequest;
16
use App\Containers\Authorization\UI\API\Requests\SyncPermissionsOnRoleRequest;
17
use App\Containers\Authorization\UI\API\Requests\SyncUserRolesRequest;
18
use App\Containers\Authorization\UI\API\Transformers\PermissionTransformer;
19
use App\Containers\Authorization\UI\API\Transformers\RoleTransformer;
20
use App\Containers\User\UI\API\Transformers\UserTransformer;
21
use App\Ship\Parents\Controllers\ApiController;
22
use App\Ship\Transporters\DataTransporter;
23
24
/**
25
 * Class Controller.
26
 *
27
 * @author Mahmoud Zalt <[email protected]>
28
 */
29
class Controller extends ApiController
30
{
31
32
    /**
33
     * @param \App\Containers\Authorization\UI\API\Requests\GetAllPermissionsRequest $request
34
     *
35
     * @return  mixed
36
     */
37
    public function getAllPermissions(GetAllPermissionsRequest $request)
38
    {
39
        $permissions = Apiato::call('[email protected]');
40
41
        return $this->transform($permissions, PermissionTransformer::class);
42
    }
43
44
    /**
45
     * @param \App\Containers\Authorization\UI\API\Requests\FindPermissionRequest $request
46
     *
47
     * @return  mixed
48
     */
49
    public function findPermission(FindPermissionRequest $request)
50
    {
51
        $permission = Apiato::call('[email protected]', [new DataTransporter($request)]);
52
53
        return $this->transform($permission, PermissionTransformer::class);
54
    }
55
56
    /**
57
     * @param \App\Containers\Authorization\UI\API\Requests\GetAllRolesRequest $request
58
     *
59
     * @return  mixed
60
     */
61
    public function getAllRoles(GetAllRolesRequest $request)
62
    {
63
        $roles = Apiato::call('[email protected]');
64
65
        return $this->transform($roles, RoleTransformer::class);
66
    }
67
68
    /**
69
     * @param \App\Containers\Authorization\UI\API\Requests\FindRoleRequest $request
70
     *
71
     * @return  mixed
72
     */
73
    public function findRole(FindRoleRequest $request)
74
    {
75
        $role = Apiato::call('[email protected]', [new DataTransporter($request)]);
76
77
        return $this->transform($role, RoleTransformer::class);
78
    }
79
80
    /**
81
     * @param \App\Containers\Authorization\UI\API\Requests\AssignUserToRoleRequest $request
82
     *
83
     * @return  mixed
84
     */
85
    public function assignUserToRole(AssignUserToRoleRequest $request)
86
    {
87
        $user = Apiato::call('[email protected]', [new DataTransporter($request)]);
88
89
        return $this->transform($user, UserTransformer::class);
90
    }
91
92
    /**
93
     * @param \App\Containers\Authorization\UI\API\Requests\SyncUserRolesRequest $request
94
     *
95
     * @return  mixed
96
     */
97
    public function syncUserRoles(SyncUserRolesRequest $request)
98
    {
99
        $user = Apiato::call('[email protected]', [new DataTransporter($request)]);
100
101
        return $this->transform($user, UserTransformer::class);
102
    }
103
104
    /**
105
     * @param \App\Containers\Authorization\UI\API\Requests\DeleteRoleRequest $request
106
     *
107
     * @return  \Illuminate\Http\JsonResponse
108
     */
109
    public function deleteRole(DeleteRoleRequest $request)
110
    {
111
        Apiato::call('[email protected]', [new DataTransporter($request)]);
112
113
        return $this->noContent();
114
    }
115
116
    /**
117
     * @param \App\Containers\Authorization\UI\API\Requests\RevokeUserFromRoleRequest $request
118
     *
119
     * @return  mixed
120
     */
121
    public function revokeRoleFromUser(RevokeUserFromRoleRequest $request)
122
    {
123
        $user = Apiato::call('[email protected]', [new DataTransporter($request)]);
124
125
        return $this->transform($user, UserTransformer::class);
126
    }
127
128
    /**
129
     * @param \App\Containers\Authorization\UI\API\Requests\AttachPermissionToRoleRequest $request
130
     *
131
     * @return  mixed
132
     */
133
    public function attachPermissionToRole(AttachPermissionToRoleRequest $request)
134
    {
135
        $role = Apiato::call('[email protected]', [new DataTransporter($request)]);
136
137
        return $this->transform($role, RoleTransformer::class);
138
    }
139
140
    /**
141
     * @param \App\Containers\Authorization\UI\API\Requests\SyncPermissionsOnRoleRequest $request
142
     *
143
     * @return  mixed
144
     */
145
    public function syncPermissionOnRole(SyncPermissionsOnRoleRequest $request)
146
    {
147
        $role = Apiato::call('[email protected]', [new DataTransporter($request)]);
148
149
        return $this->transform($role, RoleTransformer::class);
150
    }
151
152
    /**
153
     * @param \App\Containers\Authorization\UI\API\Requests\DetachPermissionToRoleRequest $request
154
     *
155
     * @return  mixed
156
     */
157
    public function detachPermissionFromRole(DetachPermissionToRoleRequest $request)
158
    {
159
        $role = Apiato::call('[email protected]', [new DataTransporter($request)]);
160
161
        return $this->transform($role, RoleTransformer::class);
162
    }
163
164
    /**
165
     * @param \App\Containers\Authorization\UI\API\Requests\CreateRoleRequest $request
166
     *
167
     * @return  mixed
168
     */
169
    public function createRole(CreateRoleRequest $request)
170
    {
171
        $role = Apiato::call('[email protected]', [new DataTransporter($request)]);
172
173
        return $this->transform($role, RoleTransformer::class);
174
    }
175
176
}
177