Completed
Branch master (090677)
by Bertrand
11:12
created
Category
app/Http/Middleware/Authenticate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
      */
15 15
     protected function redirectTo($request)
16 16
     {
17
-        if (! $request->expectsJson()) {
17
+        if (!$request->expectsJson()) {
18 18
             return route('login');
19 19
         }
20 20
     }
Please login to merge, or discard this patch.
app/Http/Controllers/UsersController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function listUsers(string $organizationId, Request $request, ListUsers $listUsers)
23 23
     {
24
-        $page = $request->input('start')/10 + 1;
24
+        $page = $request->input('start')/10+1;
25 25
 
26 26
         $users = $listUsers->list($organizationId, $page, 10);
27 27
         $total = isset($users['total']) ? $users['total'] : 0;
28 28
         $list = [];
29
-        foreach ($users['list'] as $user){
29
+        foreach ($users['list'] as $user) {
30 30
             $user = $user->toArray();
31 31
             $list[] = [
32 32
                 '',
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $lastname = $request->input('lastname') !== null ? $request->input('lastname') : '';
65 65
         $email = $request->input('email') !== null ? $request->input('email') : '';
66 66
         $picture = [];
67
-        if($request->has('logo')){
67
+        if ($request->has('logo')) {
68 68
             $picture['path_picture'] = $request->file('logo')->path();
69 69
             $picture['original_name'] = $request->file('logo')->getClientOriginalName();
70 70
             $picture['mine_type'] = $request->file('logo')->getMimeType();
Please login to merge, or discard this patch.
app/Http/Controllers/OrganizationsController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
             'city' => $city,
36 36
         ];
37 37
         $picture = [];
38
-        if($request->has('logo')){
38
+        if ($request->has('logo')) {
39 39
             $picture['path_picture'] = $request->file('logo')->path();
40 40
             $picture['original_name'] = $request->file('logo')->getClientOriginalName();
41 41
             $picture['mine_type'] = $request->file('logo')->getMimeType();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             'city' => $city,
68 68
         ];
69 69
         $picture = [];
70
-        if($request->has('logo')){
70
+        if ($request->has('logo')) {
71 71
             $picture['path_picture'] = $request->file('logo')->path();
72 72
             $picture['original_name'] = $request->file('logo')->getClientOriginalName();
73 73
             $picture['mine_type'] = $request->file('logo')->getMimeType();
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 
86 86
     public function listOrganizations(Request $request, ListOrganizations $listOrganizations)
87 87
     {
88
-        $page = $request->input('start')/10 + 1;
88
+        $page = $request->input('start')/10+1;
89 89
         $organizations = $listOrganizations->list($page, 10);
90 90
         $total = isset($organizations['total']) ? $organizations['total'] : 0;
91 91
         $list = [];
92
-        foreach ($organizations['list'] as $organization){
92
+        foreach ($organizations['list'] as $organization) {
93 93
             $org = $organization->toArray();
94 94
             $list[] = [
95 95
                 $org['name'],
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         ];
109 109
     }
110 110
 
111
-    public function prepareInvitation(Request $request,  PrepareInvitationUsersInOrganization $prepareInvitationUsersInOrganization)
111
+    public function prepareInvitation(Request $request, PrepareInvitationUsersInOrganization $prepareInvitationUsersInOrganization)
112 112
     {
113 113
         $users = $request->input('users');
114 114
         $users = explode(PHP_EOL, $users);
@@ -135,19 +135,19 @@  discard block
 block discarded – undo
135 135
     public function acceptInvite(Request $request, RespondInvitationToAnOrganization $respondInvitationToAnOrganization)
136 136
     {
137 137
         $action = $respondInvitationToAnOrganization->respond($token = $request->input('token'));
138
-        if($action['action'] == 'register'){
138
+        if ($action['action'] == 'register') {
139 139
             $request->session()->flash('should_attach_to_organization', $action['organization_id']);
140 140
             $request->session()->flash('user_to_register', $action['user']);
141 141
             return redirect()->route('register');
142 142
         }
143
-        if($action['action'] == 'accept_or_decline'){
143
+        if ($action['action'] == 'accept_or_decline') {
144 144
             $request->session()->flash('should_attach_to_organization', $action['organization_to_join']->id());
145 145
             return view('organizations.accept-or-decline-invitation', [
146 146
                 'old_organisation' => isset($action['old_organisation']) ? $action['old_organisation']->toArray() : null,
147 147
                 'organization_to_join' => isset($action['organization_to_join']) ? $action['organization_to_join']->toArray() : null
148 148
             ]);
149 149
         }
150
-        if($action['action'] == 'logout-login'){
150
+        if ($action['action'] == 'logout-login') {
151 151
             $request->session()->flash('should_attach_to_organization', $action['organization_to_join']->id());
152 152
             $request->session()->flash('should_attach_to_organization_token', $token);
153 153
             $request->session()->flash('should_attach_to_organization_redirect', route('login'));
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
             ]);
157 157
         }
158 158
 
159
-        if($action['action'] == 'login'){
159
+        if ($action['action'] == 'login') {
160 160
             $request->session()->flash('should_attach_to_organization', $action['organization_to_join']->id());
161 161
             $request->session()->flash('should_attach_to_organization_token', $token);
162 162
             $request->session()->flash('should_attach_to_organization_redirect', route('login'));
163 163
             return redirect()->route('login');
164 164
         }
165 165
 
166
-        if($action['action'] == 'logout-register'){
166
+        if ($action['action'] == 'logout-register') {
167 167
             $request->session()->flash('should_attach_to_organization', $action['organization_to_join']->id());
168 168
             $request->session()->flash('should_attach_to_organization_token', $token);
169 169
             $request->session()->flash('should_attach_to_organization_redirect', route('register'));
Please login to merge, or discard this patch.
app/Http/Controllers/Auth/RegisterController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $email = $firstname = $lastname = '';
28 28
 
29
-        if($request->session()->has('user_to_register')){
29
+        if ($request->session()->has('user_to_register')) {
30 30
             $user = $request->session()->get('user_to_register');
31 31
             $email = $user['email'];
32 32
             $firstname = $user['firstname'];
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     protected function validator(array $data)
44 44
     {
45
-        if(session()->has('should_attach_to_organization')) {
45
+        if (session()->has('should_attach_to_organization')) {
46 46
             session()->reflash();
47 47
         }
48 48
         return Validator::make($data, [
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     protected function registered(Request $request, $user)
78 78
     {
79
-        if($request->session()->has('should_attach_to_organization')){
79
+        if ($request->session()->has('should_attach_to_organization')) {
80 80
             app(AttachUserToAnOrganization::class)->attach($user->uuid, $request->session()->get('should_attach_to_organization'));
81 81
         }
82 82
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Auth/LoginController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function logout(Request $request)
30 30
     {
31
-        if($request->session()->has('should_attach_to_organization')) {
31
+        if ($request->session()->has('should_attach_to_organization')) {
32 32
             $shouldAttach = $request->session()->get('should_attach_to_organization');
33 33
             $shouldAttachToken = $request->session()->get('should_attach_to_organization_token');
34 34
             $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect');
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
         $request->session()->regenerateToken();
42 42
 
43
-        if(isset($shouldAttach)){
43
+        if (isset($shouldAttach)) {
44 44
             $request->session()->flash('should_attach_to_organization', $shouldAttach);
45 45
             $request->session()->flash('should_attach_to_organization_token', $shouldAttachToken);
46 46
             $request->session()->flash('should_attach_to_organization_redirect', $linkToRedirect);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     protected function loggedOut(Request $request)
59 59
     {
60 60
         $request->session()->reflash();
61
-        if($request->session()->has('should_attach_to_organization')){
61
+        if ($request->session()->has('should_attach_to_organization')) {
62 62
             $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect');
63 63
             return $request->wantsJson()
64 64
                 ? new Response('', 204)
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
     protected function authenticated(Request $request, $user)
70 70
     {
71
-        if($request->session()->has('should_attach_to_organization') && $request->session()->get('should_attach_to_organization') !== null){
71
+        if ($request->session()->has('should_attach_to_organization') && $request->session()->get('should_attach_to_organization') !== null) {
72 72
             $token = $request->session()->get('should_attach_to_organization_token');
73 73
             $link = route('organization.invite.show').'?&token='.$token;
74 74
             return $request->wantsJson()
Please login to merge, or discard this patch.
app/Providers/AppServiceProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 {
23 23
     public function register()
24 24
     {
25
-        if(config('app.env') === 'testing'){
25
+        if (config('app.env') === 'testing') {
26 26
             $this->app->singleton(OrganizationRepository::class, InMemoryOrganizationRepository::class);
27 27
             $this->app->singleton(PictureHandler::class, InMemoryPictureHandler::class);
28 28
             $this->app->singleton(UserRepository::class, InMemoryUserRepository::class);
29 29
             $this->app->singleton(FileStorage::class, InMemoryFileStorage::class);
30 30
             $this->app->singleton(AuthGateway::class, InMemoryAuthGateway::class);
31 31
         }
32
-        if(config('app.env') === 'testing-ti'){
32
+        if (config('app.env') === 'testing-ti') {
33 33
             $this->app->singleton(OrganizationRepository::class, SqlOrganizationRepository::class);
34 34
             $this->app->singleton(PictureHandler::class, InMemoryPictureHandler::class);
35 35
             $this->app->singleton(UserRepository::class, InMemoryUserRepository::class);
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             $this->app->singleton(FileStorage::class, InMemoryFileStorage::class);
38 38
         }
39 39
 
40
-        if(config('app.env') === 'local'){
40
+        if (config('app.env') === 'local') {
41 41
             $this->app->singleton(OrganizationRepository::class, SqlOrganizationRepository::class);
42 42
             $this->app->singleton(PictureHandler::class, StoragePictureHandler::class);
43 43
             $this->app->singleton(UserRepository::class, UserRepositorySql::class);
Please login to merge, or discard this patch.
app/Src/UseCases/Infra/InMemory/InMemoryUserRepository.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,20 +16,20 @@  discard block
 block discarded – undo
16 16
         $this->users[] = $u;
17 17
     }
18 18
 
19
-    public function getByEmail(string $email):?User
19
+    public function getByEmail(string $email): ?User
20 20
     {
21
-        foreach ($this->users as $user){
22
-            if($user->email() === $email){
21
+        foreach ($this->users as $user) {
22
+            if ($user->email() === $email) {
23 23
                 return $user;
24 24
             }
25 25
         }
26 26
         return null;
27 27
     }
28 28
 
29
-    public function getById(string $id):?User
29
+    public function getById(string $id): ?User
30 30
     {
31
-        foreach ($this->users as $user){
32
-            if($user->id() === $id){
31
+        foreach ($this->users as $user) {
32
+            if ($user->id() === $id) {
33 33
                 return $user;
34 34
             }
35 35
         }
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
     public function search(string $organizationId, int $page, int $perPage = 10): array
40 40
     {
41 41
         $users = [];
42
-        foreach($this->users as $user){
43
-            if($user->organizationId() === $organizationId){
42
+        foreach ($this->users as $user) {
43
+            if ($user->organizationId() === $organizationId) {
44 44
                 $users[] = $user;
45 45
             }
46 46
         }
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 
55 55
     public function update(User $u)
56 56
     {
57
-        foreach ($this->users as $key => $user){
58
-            if($user->id() === $u->id()){
57
+        foreach ($this->users as $key => $user) {
58
+            if ($user->id() === $u->id()) {
59 59
                 $this->users[$key] = $u;
60 60
             }
61 61
         }
Please login to merge, or discard this patch.
app/Src/UseCases/Infra/InMemory/InMemoryOrganizationRepository.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 {
12 12
     private $organizations = [];
13 13
 
14
-    public function get(string $id):? Organization
14
+    public function get(string $id): ? Organization
15 15
     {
16
-        foreach ($this->organizations as $organization){
17
-            if($organization->id() === $id){
16
+        foreach ($this->organizations as $organization) {
17
+            if ($organization->id() === $id) {
18 18
                 return $organization;
19 19
             }
20 20
         }
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function update(Organization $o)
40 40
     {
41
-        foreach ($this->organizations as $key => $organization){
42
-            if($organization->id() === $o->id()){
41
+        foreach ($this->organizations as $key => $organization) {
42
+            if ($organization->id() === $o->id()) {
43 43
                 $this->organizations[$key] = $organization;
44 44
             }
45 45
         }
Please login to merge, or discard this patch.
app/Src/UseCases/Infra/Gateway/Auth/SessionAuthGateway.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     public function current(): ?User
13 13
     {
14 14
         $userModel = Auth::user();
15
-        if(!isset($userModel)){
15
+        if (!isset($userModel)) {
16 16
             return null;
17 17
         }
18 18
         return new User($userModel->uuid, $userModel->email, $userModel->firstname, $userModel->lastname, $userModel->organization_id);
Please login to merge, or discard this patch.