Controller   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 136
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 11
lcom 0
cbo 2
dl 0
loc 136
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A updateUser() 0 6 1
A getAllUsers() 0 6 1
A getAllClients() 0 6 1
A getAllAdmins() 0 6 1
A registerUser() 0 6 1
A createAdmin() 0 6 1
A deleteUser() 0 6 1
A findUserById() 0 6 1
A getAuthenticatedUser() 0 6 1
A resetPassword() 0 6 1
A forgotPassword() 0 6 1
1
<?php
2
3
namespace App\Containers\User\UI\API\Controllers;
4
5
use Apiato\Core\Foundation\Facades\Apiato;
6
use App\Containers\User\UI\API\Requests\CreateAdminRequest;
7
use App\Containers\User\UI\API\Requests\DeleteUserRequest;
8
use App\Containers\User\UI\API\Requests\FindUserByIdRequest;
9
use App\Containers\User\UI\API\Requests\ForgotPasswordRequest;
10
use App\Containers\User\UI\API\Requests\GetAllUsersRequest;
11
use App\Containers\User\UI\API\Requests\GetAuthenticatedUserRequest;
12
use App\Containers\User\UI\API\Requests\RegisterUserRequest;
13
use App\Containers\User\UI\API\Requests\ResetPasswordRequest;
14
use App\Containers\User\UI\API\Requests\UpdateUserRequest;
15
use App\Containers\User\UI\API\Transformers\UserPrivateProfileTransformer;
16
use App\Containers\User\UI\API\Transformers\UserTransformer;
17
use App\Ship\Parents\Controllers\ApiController;
18
use App\Ship\Transporters\DataTransporter;
19
20
/**
21
 * Class Controller.
22
 *
23
 * @author Mahmoud Zalt <[email protected]>
24
 */
25
class Controller extends ApiController
26
{
27
28
    /**
29
     * @param \App\Containers\User\UI\API\Requests\RegisterUserRequest $request
30
     *
31
     * @return  mixed
32
     */
33
    public function registerUser(RegisterUserRequest $request)
34
    {
35
        $user = Apiato::call('[email protected]', [new DataTransporter($request)]);
36
37
        return $this->transform($user, UserTransformer::class);
38
    }
39
40
    /**
41
     * @param \App\Containers\User\UI\API\Requests\CreateAdminRequest $request
42
     *
43
     * @return  mixed
44
     */
45
    public function createAdmin(CreateAdminRequest $request)
46
    {
47
        $admin = Apiato::call('[email protected]', [new DataTransporter($request)]);
48
49
        return $this->transform($admin, UserTransformer::class);
50
    }
51
52
    /**
53
     * @param \App\Containers\User\UI\API\Requests\UpdateUserRequest $request
54
     *
55
     * @return  mixed
56
     */
57
    public function updateUser(UpdateUserRequest $request)
58
    {
59
        $user = Apiato::call('[email protected]', [new DataTransporter($request)]);
60
61
        return $this->transform($user, UserTransformer::class);
62
    }
63
64
    /**
65
     * @param \App\Containers\User\UI\API\Requests\DeleteUserRequest $request
66
     *
67
     * @return  \Illuminate\Http\JsonResponse
68
     */
69
    public function deleteUser(DeleteUserRequest $request)
70
    {
71
        Apiato::call('[email protected]', [new DataTransporter($request)]);
72
73
        return $this->noContent();
74
    }
75
76
    /**
77
     * @param \App\Containers\User\UI\API\Requests\GetAllUsersRequest $request
78
     *
79
     * @return  mixed
80
     */
81
    public function getAllUsers(GetAllUsersRequest $request)
82
    {
83
        $users = Apiato::call('[email protected]');
84
85
        return $this->transform($users, UserTransformer::class);
86
    }
87
88
    /**
89
     * @param \App\Containers\User\UI\API\Requests\GetAllUsersRequest $request
90
     *
91
     * @return  mixed
92
     */
93
    public function getAllClients(GetAllUsersRequest $request)
94
    {
95
        $users = Apiato::call('[email protected]');
96
97
        return $this->transform($users, UserTransformer::class);
98
    }
99
100
    /**
101
     * @param \App\Containers\User\UI\API\Requests\GetAllUsersRequest $request
102
     *
103
     * @return  mixed
104
     */
105
    public function getAllAdmins(GetAllUsersRequest $request)
106
    {
107
        $users = Apiato::call('[email protected]');
108
109
        return $this->transform($users, UserTransformer::class);
110
    }
111
112
    /**
113
     * @param \App\Containers\User\UI\API\Requests\FindUserByIdRequest $request
114
     *
115
     * @return  mixed
116
     */
117
    public function findUserById(FindUserByIdRequest $request)
118
    {
119
        $user = Apiato::call('[email protected]', [new DataTransporter($request)]);
120
121
        return $this->transform($user, UserTransformer::class);
122
    }
123
124
    /**
125
     * @param GetAuthenticatedUserRequest $request
126
     *
127
     * @return mixed
128
     */
129
    public function getAuthenticatedUser(GetAuthenticatedUserRequest $request)
130
    {
131
        $user = Apiato::call('[email protected]');
132
133
        return $this->transform($user, UserPrivateProfileTransformer::class);
134
    }
135
136
    /**
137
     * @param \App\Containers\User\UI\API\Requests\ResetPasswordRequest $request
138
     *
139
     * @return  \Illuminate\Http\JsonResponse
140
     */
141
    public function resetPassword(ResetPasswordRequest $request)
142
    {
143
        Apiato::call('[email protected]', [new DataTransporter($request)]);
144
145
        return $this->noContent(204);
146
    }
147
148
    /**
149
     * @param \App\Containers\User\UI\API\Requests\ForgotPasswordRequest $request
150
     *
151
     * @return  \Illuminate\Http\JsonResponse
152
     */
153
    public function forgotPassword(ForgotPasswordRequest $request)
154
    {
155
        Apiato::call('[email protected]', [new DataTransporter($request)]);
156
157
        return $this->noContent(202);
158
    }
159
160
}
161