Passed
Pull Request — master (#14)
by ARCANEDEV
08:06
created
src/Authorization/Policies/UsersPolicy.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -197,8 +197,9 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function activate(Administrator $administrator, User $user = null)
199 199
     {
200
-        if ( ! is_null($user) && $user->isActive())
201
-            return false;
200
+        if ( ! is_null($user) && $user->isActive()) {
201
+                    return false;
202
+        }
202 203
     }
203 204
 
204 205
     /**
@@ -211,8 +212,9 @@  discard block
 block discarded – undo
211 212
      */
212 213
     public function deactivate(Administrator $administrator, User $user = null)
213 214
     {
214
-        if ( ! is_null($user) && ! $user->isActive())
215
-            return false;
215
+        if ( ! is_null($user) && ! $user->isActive()) {
216
+                    return false;
217
+        }
216 218
     }
217 219
 
218 220
     /**
@@ -225,8 +227,9 @@  discard block
 block discarded – undo
225 227
      */
226 228
     public function delete(Administrator $administrator, User $user = null)
227 229
     {
228
-        if ( ! is_null($user))
229
-            return $user->isDeletable();
230
+        if ( ! is_null($user)) {
231
+                    return $user->isDeletable();
232
+        }
230 233
     }
231 234
 
232 235
     /**
@@ -239,8 +242,9 @@  discard block
 block discarded – undo
239 242
      */
240 243
     public function forceDelete(Administrator $administrator, User $user = null)
241 244
     {
242
-        if ( ! is_null($user))
243
-            return $user->isDeletable();
245
+        if ( ! is_null($user)) {
246
+                    return $user->isDeletable();
247
+        }
244 248
     }
245 249
 
246 250
     /**
Please login to merge, or discard this patch.
src/Authorization/Policies/PermissionsPolicy.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,7 +109,8 @@
 block discarded – undo
109 109
      */
110 110
     public function detachRole(Administrator $administrator, Permission $permission = null, Role $role = null)
111 111
     {
112
-        if ( ! is_null($role))
113
-            return ! $role->isLocked();
112
+        if ( ! is_null($role)) {
113
+                    return ! $role->isLocked();
114
+        }
114 115
     }
115 116
 }
Please login to merge, or discard this patch.
src/Authorization/Policies/AdministratorsPolicy.php 1 patch
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -147,8 +147,9 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function show(Administrator $administrator, Administrator $model = null)
149 149
     {
150
-        if ($model && $model->isSuperAdmin() && ! $administrator->isSuperAdmin())
151
-            return false;
150
+        if ($model && $model->isSuperAdmin() && ! $administrator->isSuperAdmin()) {
151
+                    return false;
152
+        }
152 153
     }
153 154
 
154 155
     /**
@@ -186,14 +187,17 @@  discard block
 block discarded – undo
186 187
      */
187 188
     public function activate(Administrator $administrator, Administrator $model = null)
188 189
     {
189
-        if ( ! is_null($model) && $model->isActive())
190
-            return false;
190
+        if ( ! is_null($model) && $model->isActive()) {
191
+                    return false;
192
+        }
191 193
 
192
-        if ($administrator->is($model))
193
-            return false;
194
+        if ($administrator->is($model)) {
195
+                    return false;
196
+        }
194 197
 
195
-        if ( ! is_null($model) && $model->isSuperAdmin())
196
-            return false;
198
+        if ( ! is_null($model) && $model->isSuperAdmin()) {
199
+                    return false;
200
+        }
197 201
     }
198 202
 
199 203
     /**
@@ -206,14 +210,17 @@  discard block
 block discarded – undo
206 210
      */
207 211
     public function deactivate(Administrator $administrator, Administrator $model = null)
208 212
     {
209
-        if ( ! is_null($model) && ! $model->isActive())
210
-            return false;
213
+        if ( ! is_null($model) && ! $model->isActive()) {
214
+                    return false;
215
+        }
211 216
 
212
-        if ($administrator->is($model))
213
-            return false;
217
+        if ($administrator->is($model)) {
218
+                    return false;
219
+        }
214 220
 
215
-        if ( ! is_null($model) && $model->isSuperAdmin())
216
-            return false;
221
+        if ( ! is_null($model) && $model->isSuperAdmin()) {
222
+                    return false;
223
+        }
217 224
     }
218 225
 
219 226
     /**
@@ -226,11 +233,13 @@  discard block
 block discarded – undo
226 233
      */
227 234
     public function delete(Administrator $administrator, Administrator $model = null)
228 235
     {
229
-        if ($administrator->is($model))
230
-            return false;
236
+        if ($administrator->is($model)) {
237
+                    return false;
238
+        }
231 239
 
232
-        if ( ! is_null($model))
233
-            return $model->isDeletable();
240
+        if ( ! is_null($model)) {
241
+                    return $model->isDeletable();
242
+        }
234 243
     }
235 244
 
236 245
     /**
@@ -243,8 +252,9 @@  discard block
 block discarded – undo
243 252
      */
244 253
     public function forceDelete(Administrator $administrator, Administrator $model = null)
245 254
     {
246
-        if ( ! is_null($model))
247
-            return $model->isDeletable();
255
+        if ( ! is_null($model)) {
256
+                    return $model->isDeletable();
257
+        }
248 258
     }
249 259
 
250 260
     /**
@@ -257,7 +267,8 @@  discard block
 block discarded – undo
257 267
      */
258 268
     public function restore(Administrator $administrator, Administrator $model = null)
259 269
     {
260
-        if ( ! is_null($model))
261
-            return $model->trashed();
270
+        if ( ! is_null($model)) {
271
+                    return $model->trashed();
272
+        }
262 273
     }
263 274
 }
Please login to merge, or discard this patch.
src/Authorization/Policies/RolesPolicy.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -129,8 +129,9 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function show(Administrator $administrator, Role $role = null)
131 131
     {
132
-        if ($role && $role->isAdministrator() && ! $administrator->isSuperAdmin())
133
-            return false;
132
+        if ($role && $role->isAdministrator() && ! $administrator->isSuperAdmin()) {
133
+                    return false;
134
+        }
134 135
     }
135 136
 
136 137
     /**
@@ -155,8 +156,9 @@  discard block
 block discarded – undo
155 156
      */
156 157
     public function update(Administrator $administrator, Role $role = null)
157 158
     {
158
-        if (static::isRoleLocked($role))
159
-            return false;
159
+        if (static::isRoleLocked($role)) {
160
+                    return false;
161
+        }
160 162
     }
161 163
 
162 164
     /**
@@ -169,11 +171,13 @@  discard block
 block discarded – undo
169 171
      */
170 172
     public function activate(Administrator $administrator, Role $role = null)
171 173
     {
172
-        if (static::isRoleLocked($role))
173
-            return false;
174
+        if (static::isRoleLocked($role)) {
175
+                    return false;
176
+        }
174 177
 
175
-        if ( ! is_null($role) && $role->isActive())
176
-            return false;
178
+        if ( ! is_null($role) && $role->isActive()) {
179
+                    return false;
180
+        }
177 181
     }
178 182
 
179 183
     /**
@@ -186,11 +190,13 @@  discard block
 block discarded – undo
186 190
      */
187 191
     public function deactivate(Administrator $administrator, Role $role = null)
188 192
     {
189
-        if (static::isRoleLocked($role))
190
-            return false;
193
+        if (static::isRoleLocked($role)) {
194
+                    return false;
195
+        }
191 196
 
192
-        if ( ! is_null($role) && ! $role->isActive())
193
-            return false;
197
+        if ( ! is_null($role) && ! $role->isActive()) {
198
+                    return false;
199
+        }
194 200
     }
195 201
 
196 202
     /**
@@ -203,8 +209,9 @@  discard block
 block discarded – undo
203 209
      */
204 210
     public function delete(Administrator $administrator, Role $role = null)
205 211
     {
206
-        if ( ! is_null($role))
207
-            return $role->isDeletable();
212
+        if ( ! is_null($role)) {
213
+                    return $role->isDeletable();
214
+        }
208 215
     }
209 216
 
210 217
     /**
@@ -218,8 +225,9 @@  discard block
 block discarded – undo
218 225
      */
219 226
     public function detachAdministrator(Administrator $administrator, Role $role = null, Administrator $model = null)
220 227
     {
221
-        if ( ! $administrator->isSuperAdmin() && $model->isSuperAdmin())
222
-            return false;
228
+        if ( ! $administrator->isSuperAdmin() && $model->isSuperAdmin()) {
229
+                    return false;
230
+        }
223 231
     }
224 232
 
225 233
     /**
@@ -233,8 +241,9 @@  discard block
 block discarded – undo
233 241
      */
234 242
     public function detachPermission(Administrator $administrator, Role $role = null, Permission $model = null)
235 243
     {
236
-        if (static::isRoleLocked($role))
237
-            return false;
244
+        if (static::isRoleLocked($role)) {
245
+                    return false;
246
+        }
238 247
     }
239 248
 
240 249
     /* -----------------------------------------------------------------
Please login to merge, or discard this patch.
src/Authorization/Models/Concerns/HasRoles.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function getActiveRolesAttribute()
44 44
     {
45
-        return $this->roles->filter(function (Role $role) {
45
+        return $this->roles->filter(function(Role $role) {
46 46
             return $role->isActive();
47 47
         });
48 48
     }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $roles = is_array($roles) ? new Collection($roles) : $roles;
95 95
 
96
-        $failed = $roles->reject(function ($role) {
96
+        $failed = $roles->reject(function($role) {
97 97
             return $this->hasRoleKey($role);
98 98
         })->values();
99 99
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function hasRoleKey(string $key): bool
111 111
     {
112
-        return $this->active_roles->filter(function (Role $role) use ($key) {
112
+        return $this->active_roles->filter(function(Role $role) use ($key) {
113 113
             return $role->hasKey($key);
114 114
         })->isNotEmpty();
115 115
     }
Please login to merge, or discard this patch.
src/Authorization/Models/Concerns/HasPassword.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@
 block discarded – undo
28 28
      */
29 29
     public function setPasswordAttribute($password)
30 30
     {
31
-        if (is_null($password))
32
-            return;
31
+        if (is_null($password)) {
32
+                    return;
33
+        }
33 34
 
34 35
         $this->attributes['password'] = Hash::make($password);
35 36
     }
Please login to merge, or discard this patch.
src/Authorization/Models/Presenters/PermissionPresenter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
      */
31 31
     public function getUsersCountAttribute(): int
32 32
     {
33
-        return $this->roles->sum(function (Role $role) {
33
+        return $this->roles->sum(function(Role $role) {
34 34
             return $role->administrators->count();
35 35
         });
36 36
     }
Please login to merge, or discard this patch.
src/Authorization/Models/Presenters/AuthenticatablePresenter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
         $show  = 2;
97 97
         $parts = explode('@', $this->email);
98 98
 
99
-        return substr($parts[0],0, $show).str_repeat('*', 3).'@'.$parts[1];
99
+        return substr($parts[0], 0, $show).str_repeat('*', 3).'@'.$parts[1];
100 100
     }
101 101
 
102 102
     /**
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function getDisplayNameAttribute(): string
36 36
     {
37
-        if ($this->hasName())
38
-            return $this->getFullNameAttribute();
37
+        if ($this->hasName()) {
38
+                    return $this->getFullNameAttribute();
39
+        }
39 40
 
40 41
         return $this->username;
41 42
     }
@@ -57,8 +58,9 @@  discard block
 block discarded – undo
57 58
      */
58 59
     public function setFirstNameAttribute($firstName)
59 60
     {
60
-        if (is_null($firstName))
61
-            return;
61
+        if (is_null($firstName)) {
62
+                    return;
63
+        }
62 64
 
63 65
         $this->attributes['first_name'] = Str::title(Str::lower($firstName));
64 66
     }
@@ -70,8 +72,9 @@  discard block
 block discarded – undo
70 72
      */
71 73
     public function setLastNameAttribute($lastName)
72 74
     {
73
-        if (is_null($lastName))
74
-            return;
75
+        if (is_null($lastName)) {
76
+                    return;
77
+        }
75 78
 
76 79
         $this->attributes['last_name'] = Str::upper($lastName);
77 80
     }
@@ -135,8 +138,9 @@  discard block
 block discarded – undo
135 138
      */
136 139
     public function getLastActivityAttribute(): string
137 140
     {
138
-        if (is_null($this->last_activity_at))
139
-            return __('No recent activity');
141
+        if (is_null($this->last_activity_at)) {
142
+                    return __('No recent activity');
143
+        }
140 144
 
141 145
         return $this->last_activity_at->diffForHumans();
142 146
     }
Please login to merge, or discard this patch.
src/Authorization/Models/PermissionsGroup.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -311,7 +311,7 @@
 block discarded – undo
311 311
         $this->loadPermissions();
312 312
 
313 313
         return $this->permissions
314
-            ->filter(function (Permission $permission) use ($id) {
314
+            ->filter(function(Permission $permission) use ($id) {
315 315
                 return $permission->getKey() == $id;
316 316
             })
317 317
             ->first();
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -170,8 +170,9 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function attachPermission(&$permission, bool $reload = true)
172 172
     {
173
-        if ($this->hasPermission($permission))
174
-            return;
173
+        if ($this->hasPermission($permission)) {
174
+                    return;
175
+        }
175 176
 
176 177
         event(new AttachingPermission($this, $permission));
177 178
         $permission = $this->permissions()->save($permission);
@@ -192,8 +193,9 @@  discard block
 block discarded – undo
192 193
     {
193 194
         $permission = $this->getPermissionById($id);
194 195
 
195
-        if ($permission !== null)
196
-            $this->attachPermission($permission, $reload);
196
+        if ($permission !== null) {
197
+                    $this->attachPermission($permission, $reload);
198
+        }
197 199
 
198 200
         return $permission;
199 201
     }
@@ -225,8 +227,9 @@  discard block
 block discarded – undo
225 227
      */
226 228
     public function detachPermission(&$permission, bool $reload = true)
227 229
     {
228
-        if ( ! $this->hasPermission($permission))
229
-            return;
230
+        if ( ! $this->hasPermission($permission)) {
231
+                    return;
232
+        }
230 233
 
231 234
         $permission = $this->getPermissionFromGroup($permission);
232 235
 
@@ -247,8 +250,9 @@  discard block
 block discarded – undo
247 250
      */
248 251
     public function detachPermissionById($id, bool $reload = true)
249 252
     {
250
-        if ( ! is_null($permission = $this->getPermissionById($id)))
251
-            $this->detachPermission($permission, $reload);
253
+        if ( ! is_null($permission = $this->getPermissionById($id))) {
254
+                    $this->detachPermission($permission, $reload);
255
+        }
252 256
 
253 257
         return $permission;
254 258
     }
@@ -296,8 +300,9 @@  discard block
 block discarded – undo
296 300
      */
297 301
     public function hasPermission($id)
298 302
     {
299
-        if ($id instanceof Model)
300
-            $id = $id->getKey();
303
+        if ($id instanceof Model) {
304
+                    $id = $id->getKey();
305
+        }
301 306
 
302 307
         return $this->getPermissionFromGroup($id) !== null;
303 308
     }
@@ -316,8 +321,9 @@  discard block
 block discarded – undo
316 321
      */
317 322
     private function getPermissionFromGroup($id)
318 323
     {
319
-        if ($id instanceof Model)
320
-            $id = $id->getKey();
324
+        if ($id instanceof Model) {
325
+                    $id = $id->getKey();
326
+        }
321 327
 
322 328
         $this->loadPermissions();
323 329
 
Please login to merge, or discard this patch.