Passed
Push — master ( 019307...8b3c0e )
by
unknown
03:05
created
src/Detector.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 
90 90
         // First we need to check restritions for given Role
91 91
         // to detect special Location, IP, Hours conditions.
92
-        if (! $this->checkRestrictions()) return $this->denied;
92
+        if (!$this->checkRestrictions()) return $this->denied;
93 93
 
94
-        return $this->hasModel($model, $relation) ? $this->allowed: $this->denied;
94
+        return $this->hasModel($model, $relation) ? $this->allowed : $this->denied;
95 95
     }
96 96
 
97 97
     /**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
         // First we need to check restritions for given Role
110 110
         // to detect special Location, IP, Hours conditions.
111
-        if (! $this->checkRestrictions()) return $this->denied;
111
+        if (!$this->checkRestrictions()) return $this->denied;
112 112
 
113 113
         if ($this->hasModel($model, $relation)) return $this->allowed;
114 114
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
         // First we need to check restritions for given Role
130 130
         // to detect special Location, IP, Hours conditions.
131
-        if (! $this->checkRestrictions()) return $this->denied;
131
+        if (!$this->checkRestrictions()) return $this->denied;
132 132
 
133 133
         return $this->hasLevel($min) ? $this->allowed : $this->denied;
134 134
     }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
         // First we need to check restritions for given Role
149 149
         // to detect special Location, IP, Hours conditions.
150
-        if (! $this->checkRestrictions()) return $this->denied;
150
+        if (!$this->checkRestrictions()) return $this->denied;
151 151
 
152 152
         return $this->isOwner($model, $foreign) ? $this->allowed : $this->denied;
153 153
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
         // First we need to check restritions for given Role
169 169
         // to detect special Location, IP, Hours conditions.
170
-        if (! $this->checkRestrictions()) return $this->denied;
170
+        if (!$this->checkRestrictions()) return $this->denied;
171 171
 
172 172
         if ($this->isOwner($model, $foreign)) return $this->allowed;
173 173
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
         // First we need to check restritions for given Role
204 204
         // to detect special Location, IP, Hours conditions.
205
-        if (! $this->checkRestrictions()) return $this->denied;
205
+        if (!$this->checkRestrictions()) return $this->denied;
206 206
 
207 207
         return $this->isSharing($model, $modelRelation, $relation) ?
208 208
             $this->allowed : $this->denied;
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,7 +89,9 @@  discard block
 block discarded – undo
89 89
 
90 90
         // First we need to check restritions for given Role
91 91
         // to detect special Location, IP, Hours conditions.
92
-        if (! $this->checkRestrictions()) return $this->denied;
92
+        if (! $this->checkRestrictions()) {
93
+            return $this->denied;
94
+        }
93 95
 
94 96
         return $this->hasModel($model, $relation) ? $this->allowed: $this->denied;
95 97
     }
@@ -108,9 +110,13 @@  discard block
 block discarded – undo
108 110
 
109 111
         // First we need to check restritions for given Role
110 112
         // to detect special Location, IP, Hours conditions.
111
-        if (! $this->checkRestrictions()) return $this->denied;
113
+        if (! $this->checkRestrictions()) {
114
+            return $this->denied;
115
+        }
112 116
 
113
-        if ($this->hasModel($model, $relation)) return $this->allowed;
117
+        if ($this->hasModel($model, $relation)) {
118
+            return $this->allowed;
119
+        }
114 120
 
115 121
         return $this->hasLevel($min) ? $this->allowed : $this->denied;
116 122
     }
@@ -128,7 +134,9 @@  discard block
 block discarded – undo
128 134
 
129 135
         // First we need to check restritions for given Role
130 136
         // to detect special Location, IP, Hours conditions.
131
-        if (! $this->checkRestrictions()) return $this->denied;
137
+        if (! $this->checkRestrictions()) {
138
+            return $this->denied;
139
+        }
132 140
 
133 141
         return $this->hasLevel($min) ? $this->allowed : $this->denied;
134 142
     }
@@ -147,7 +155,9 @@  discard block
 block discarded – undo
147 155
 
148 156
         // First we need to check restritions for given Role
149 157
         // to detect special Location, IP, Hours conditions.
150
-        if (! $this->checkRestrictions()) return $this->denied;
158
+        if (! $this->checkRestrictions()) {
159
+            return $this->denied;
160
+        }
151 161
 
152 162
         return $this->isOwner($model, $foreign) ? $this->allowed : $this->denied;
153 163
     }
@@ -167,9 +177,13 @@  discard block
 block discarded – undo
167 177
 
168 178
         // First we need to check restritions for given Role
169 179
         // to detect special Location, IP, Hours conditions.
170
-        if (! $this->checkRestrictions()) return $this->denied;
180
+        if (! $this->checkRestrictions()) {
181
+            return $this->denied;
182
+        }
171 183
 
172
-        if ($this->isOwner($model, $foreign)) return $this->allowed;
184
+        if ($this->isOwner($model, $foreign)) {
185
+            return $this->allowed;
186
+        }
173 187
 
174 188
         return $this->hasLevel($min) ? $this->allowed : $this->denied;
175 189
     }
@@ -202,7 +216,9 @@  discard block
 block discarded – undo
202 216
 
203 217
         // First we need to check restritions for given Role
204 218
         // to detect special Location, IP, Hours conditions.
205
-        if (! $this->checkRestrictions()) return $this->denied;
219
+        if (! $this->checkRestrictions()) {
220
+            return $this->denied;
221
+        }
206 222
 
207 223
         return $this->isSharing($model, $modelRelation, $relation) ?
208 224
             $this->allowed : $this->denied;
Please login to merge, or discard this patch.
database/migrations/2018_10_14_120000_create_priv_roles_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('priv_roles', function (Blueprint $table) {
16
+        Schema::create('priv_roles', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->string('name')->unique();
19 19
             $table->unsignedTinyInteger('level')->default(0); // Visitor,Employee,Manager,Director
Please login to merge, or discard this patch.
database/migrations/2018_10_14_120002_create_priv_user_role_table.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@
 block discarded – undo
34 34
             $table->unsignedInteger('role_id');
35 35
 
36 36
             $table->foreign('auth_id')
37
-                  ->references($config['key'])->on($config['table'])
38
-                  ->onDelete('CASCADE');
37
+                    ->references($config['key'])->on($config['table'])
38
+                    ->onDelete('CASCADE');
39 39
 
40 40
             $table->foreign('role_id')
41
-                  ->references('id')->on('priv_roles')
42
-                  ->onDelete('CASCADE');
41
+                    ->references('id')->on('priv_roles')
42
+                    ->onDelete('CASCADE');
43 43
         });
44 44
     }
45 45
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     {
18 18
         $config = Manager::getAuthorizableMigration();
19 19
 
20
-        Schema::create('priv_auth_role', function (Blueprint $table) use ($config) {
20
+        Schema::create('priv_auth_role', function(Blueprint $table) use ($config) {
21 21
             // Depend on Authorizable table structure
22 22
             // package provides support for tree types
23 23
             // of primaryKey: integer, string & uuid.
Please login to merge, or discard this patch.
database/migrations/2018_10_14_120001_create_priv_permissions_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('priv_permissions', function (Blueprint $table) {
16
+        Schema::create('priv_permissions', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->morphs('grantable');
19 19
             $table->string('scope');
Please login to merge, or discard this patch.
src/PrivilegesServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
28 28
 
29
-        $this->publishes([__DIR__ .'/../config/privileges.php' => config_path('privileges.php')], 'config');
29
+        $this->publishes([__DIR__.'/../config/privileges.php' => config_path('privileges.php')], 'config');
30 30
 
31 31
         $this->publishes([__DIR__.'/../database/migrations/' => database_path('migrations')], 'migrations');
32 32
     }
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function register()
40 40
     {
41
-        $this->mergeConfigFrom(__DIR__ .'/../config/privileges.php', 'privileges');
41
+        $this->mergeConfigFrom(__DIR__.'/../config/privileges.php', 'privileges');
42 42
 
43
-        $this->app->singleton('mrluke-privileges-detector', function ($app) {
43
+        $this->app->singleton('mrluke-privileges-detector', function($app) {
44 44
 
45 45
             $manager = $app->make('mrluke-privileges-manager');
46 46
 
47 47
             return new \Mrluke\Privileges\Detector($manager);
48 48
         });
49 49
 
50
-        $this->app->singleton('mrluke-privileges-manager', function ($app) {
50
+        $this->app->singleton('mrluke-privileges-manager', function($app) {
51 51
 
52 52
             $schema = \Mrluke\Configuration\Schema::createFromFile(
53 53
                 __DIR__.'/../config/schema.json',
Please login to merge, or discard this patch.
src/Manager.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     public function detectScope(string $model)
171 171
     {
172 172
         return $this->config->get(
173
-            'mapping.' . $model,
173
+            'mapping.'.$model,
174 174
             $this->config->get('mapping_default')
175 175
         );
176 176
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         if (':*' === substr($scope, -2)) {
234 234
             $scope = substr($scope, 0, -2);
235 235
 
236
-            return $subject->permissions->sortbyDesc('level')->first(function ($perm) use ($scope) {
236
+            return $subject->permissions->sortbyDesc('level')->first(function($perm) use ($scope) {
237 237
                 return preg_match("/^(${scope}$|${scope}:)/", $perm['scope']);
238 238
             });
239 239
         }
Please login to merge, or discard this patch.
src/PermissionResolver.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public static function getScopeRestrictions($subject, string $scope, int $level = null): array
23 23
     {
24
-        $scopes = $subject->roles->flatMap(function ($role) use ($scope, $level) {
24
+        $scopes = $subject->roles->flatMap(function($role) use ($scope, $level) {
25 25
             if ($level) {
26 26
                 $permissions = $role->permissions->where('level', $level);
27 27
             } else {
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
             return preg_grep("/^${scope}:/", array_column($permissions->toArray(), 'scope'));
32 32
         })->toArray();
33 33
 
34
-        return array_map(function ($val) use ($scope) {
35
-            return str_replace($scope . ':', '', $val);
34
+        return array_map(function($val) use ($scope) {
35
+            return str_replace($scope.':', '', $val);
36 36
         }, $scopes);
37 37
     }
38 38
 }
Please login to merge, or discard this patch.