| @@ -250,16 +250,13 @@ | ||
| 250 | 250 | if ($object instanceof RoleInterface) | 
| 251 | 251 |  			{ | 
| 252 | 252 | $this->addRole((string)$object); | 
| 253 | - } | |
| 254 | - else if ($object instanceof ResourceInterface) | |
| 253 | + } else if ($object instanceof ResourceInterface) | |
| 255 | 254 |  			{ | 
| 256 | 255 | $this->addResource((string)$object); | 
| 257 | - } | |
| 258 | - else if ($object instanceof PermissionInterface) | |
| 256 | + } else if ($object instanceof PermissionInterface) | |
| 259 | 257 |  			{ | 
| 260 | 258 | $this->addPermission((string)$object); | 
| 261 | - } | |
| 262 | -			else { | |
| 259 | +			} else { | |
| 263 | 260 | throw new \Exception( | 
| 264 | 261 | sprintf( | 
| 265 | 262 | "%s must implement one of RoleInterface, '. | 
| @@ -192,7 +192,7 @@ discard block | ||
| 192 | 192 | /** | 
| 193 | 193 | * Add a new role object to the registry | 
| 194 | 194 | * | 
| 195 | - * @param string[] $role | |
| 195 | + * @param string $role | |
| 196 | 196 | * @return void | 
| 197 | 197 | */ | 
| 198 | 198 | public function addRole(string ...$role) | 
| @@ -206,7 +206,7 @@ discard block | ||
| 206 | 206 | /** | 
| 207 | 207 | * Add a new resource object to the registry | 
| 208 | 208 | * | 
| 209 | - * @param string[] $resource | |
| 209 | + * @param string $resource | |
| 210 | 210 | * @return void | 
| 211 | 211 | */ | 
| 212 | 212 | public function addResource(string ...$resource) | 
| @@ -220,7 +220,7 @@ discard block | ||
| 220 | 220 | /** | 
| 221 | 221 | * Add a new permission object to the registry | 
| 222 | 222 | * | 
| 223 | - * @param string[] $permission | |
| 223 | + * @param string $permission | |
| 224 | 224 | * @return void | 
| 225 | 225 | */ | 
| 226 | 226 | public function addPermission(string ...$permission) | 
| @@ -1,4 +1,4 @@ discard block | ||
| 1 | -<?php declare(strict_types=1); | |
| 1 | +<?php declare(strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library | 
| @@ -279,7 +279,7 @@ discard block | ||
| 279 | 279 | * @throws \Exception | 
| 280 | 280 | * @return void | 
| 281 | 281 | */ | 
| 282 | - public function allow(string $role, string $permission, string $resource, bool $status=null) | |
| 282 | + public function allow(string $role, string $permission, string $resource, bool $status = null) | |
| 283 | 283 |  	{ | 
| 284 | 284 | $status = $status ?? true; | 
| 285 | 285 |  		if (!$this->roleRegistry->exists($role)) { | 
| @@ -133,22 +133,22 @@ discard block | ||
| 133 | 133 | ); | 
| 134 | 134 | } | 
| 135 | 135 | |
| 136 | - $this->session["role"] = $role; | |
| 137 | - | |
| 138 | - return $this; | |
| 139 | - } | |
| 140 | - | |
| 141 | - /** | |
| 142 | - * Listen for and intercept undefined methods | |
| 143 | - * | |
| 144 | - * @param string $permission | |
| 145 | - * @param string[] $args | |
| 146 | - * @throws \Exception | |
| 147 | - * @return boolean|null | |
| 148 | - */ | |
| 149 | - public function __call(string $permission, array $args) | |
| 150 | -	{ | |
| 151 | -		if (!$this->permissionRegistry->exists($permission)) { | |
| 136 | + $this->session["role"] = $role; | |
| 137 | + | |
| 138 | + return $this; | |
| 139 | + } | |
| 140 | + | |
| 141 | + /** | |
| 142 | + * Listen for and intercept undefined methods | |
| 143 | + * | |
| 144 | + * @param string $permission | |
| 145 | + * @param string[] $args | |
| 146 | + * @throws \Exception | |
| 147 | + * @return boolean|null | |
| 148 | + */ | |
| 149 | + public function __call(string $permission, array $args) | |
| 150 | +    { | |
| 151 | +        if (!$this->permissionRegistry->exists($permission)) { | |
| 152 | 152 | throw new \Exception( | 
| 153 | 153 | sprintf( | 
| 154 | 154 | "The permission: %s doesnt exist", | 
| @@ -170,9 +170,9 @@ discard block | ||
| 170 | 170 | |
| 171 | 171 | $args = (count($args) > 0) ? $args : $this->resourceRegistry->getRegistryNames(); | 
| 172 | 172 | |
| 173 | - if ($this->session["query"]) | |
| 174 | -		{ | |
| 175 | - foreach ($args as $arg) | |
| 173 | + if ($this->session["query"]) | |
| 174 | +        { | |
| 175 | + foreach ($args as $arg) | |
| 176 | 176 |              { | 
| 177 | 177 | $result = $this->getPermissionStatus( | 
| 178 | 178 | $this->session["role"], | 
| @@ -189,7 +189,7 @@ discard block | ||
| 189 | 189 | $this->initSession(); | 
| 190 | 190 | |
| 191 | 191 | return $result; | 
| 192 | - } | |
| 192 | + } | |
| 193 | 193 | |
| 194 | 194 |          foreach ($args as $arg) { | 
| 195 | 195 | $this->allow( | 
| @@ -200,103 +200,103 @@ discard block | ||
| 200 | 200 | ); | 
| 201 | 201 | } | 
| 202 | 202 | |
| 203 | - $this->initSession(); | |
| 204 | - } | |
| 205 | - | |
| 206 | - /** | |
| 207 | - * Add a new role object to the registry | |
| 208 | - * | |
| 209 | - * @param string[] $role | |
| 210 | - * @return void | |
| 211 | - */ | |
| 212 | - public function addRole(string ...$role) | |
| 213 | -	{ | |
| 214 | - foreach ($role as $_role) | |
| 215 | -		{ | |
| 216 | - $this->roleRegistry->save($_role); | |
| 217 | - } | |
| 218 | - } | |
| 219 | - | |
| 220 | - /** | |
| 221 | - * Add a new resource object to the registry | |
| 222 | - * | |
| 223 | - * @param string[] $resource | |
| 224 | - * @return void | |
| 225 | - */ | |
| 226 | - public function addResource(string ...$resource) | |
| 227 | -	{ | |
| 228 | - foreach ($resource as $_resource) | |
| 229 | -		{ | |
| 230 | - $this->resourceRegistry->save($_resource); | |
| 231 | - } | |
| 232 | - } | |
| 233 | - | |
| 234 | - /** | |
| 235 | - * Add a new permission object to the registry | |
| 236 | - * | |
| 237 | - * @param string[] $permission | |
| 238 | - * @return void | |
| 239 | - */ | |
| 240 | - public function addPermission(string ...$permission) | |
| 241 | -	{ | |
| 242 | - foreach ($permission as $_permission) | |
| 243 | -		{ | |
| 244 | - $this->permissionRegistry->save($_permission); | |
| 245 | - } | |
| 246 | - } | |
| 247 | - | |
| 248 | - /** | |
| 249 | - * Adds objects lazily. | |
| 250 | - * | |
| 251 | - * Automatically determine the type of an object and call the appropriate | |
| 252 | - * add method on it. | |
| 253 | - * | |
| 254 | - * @param ObjectInterface[] $objects | |
| 255 | - * @throws \Exception | |
| 256 | - * @return void | |
| 257 | - */ | |
| 258 | - public function add(ObjectInterface ...$objects) | |
| 259 | -	{ | |
| 260 | - foreach ($objects as $object) | |
| 261 | -		{ | |
| 262 | - if ($object instanceof RoleInterface) | |
| 263 | -			{ | |
| 264 | - $this->addRole((string)$object); | |
| 265 | - } | |
| 266 | - else if ($object instanceof ResourceInterface) | |
| 267 | -			{ | |
| 268 | - $this->addResource((string)$object); | |
| 269 | - } | |
| 270 | - else if ($object instanceof PermissionInterface) | |
| 271 | -			{ | |
| 272 | - $this->addPermission((string)$object); | |
| 273 | - } | |
| 274 | -			else { | |
| 275 | - throw new \Exception( | |
| 276 | - sprintf( | |
| 277 | - "%s must implement one of RoleInterface, '. | |
| 203 | + $this->initSession(); | |
| 204 | + } | |
| 205 | + | |
| 206 | + /** | |
| 207 | + * Add a new role object to the registry | |
| 208 | + * | |
| 209 | + * @param string[] $role | |
| 210 | + * @return void | |
| 211 | + */ | |
| 212 | + public function addRole(string ...$role) | |
| 213 | +    { | |
| 214 | + foreach ($role as $_role) | |
| 215 | +        { | |
| 216 | + $this->roleRegistry->save($_role); | |
| 217 | + } | |
| 218 | + } | |
| 219 | + | |
| 220 | + /** | |
| 221 | + * Add a new resource object to the registry | |
| 222 | + * | |
| 223 | + * @param string[] $resource | |
| 224 | + * @return void | |
| 225 | + */ | |
| 226 | + public function addResource(string ...$resource) | |
| 227 | +    { | |
| 228 | + foreach ($resource as $_resource) | |
| 229 | +        { | |
| 230 | + $this->resourceRegistry->save($_resource); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + /** | |
| 235 | + * Add a new permission object to the registry | |
| 236 | + * | |
| 237 | + * @param string[] $permission | |
| 238 | + * @return void | |
| 239 | + */ | |
| 240 | + public function addPermission(string ...$permission) | |
| 241 | +    { | |
| 242 | + foreach ($permission as $_permission) | |
| 243 | +        { | |
| 244 | + $this->permissionRegistry->save($_permission); | |
| 245 | + } | |
| 246 | + } | |
| 247 | + | |
| 248 | + /** | |
| 249 | + * Adds objects lazily. | |
| 250 | + * | |
| 251 | + * Automatically determine the type of an object and call the appropriate | |
| 252 | + * add method on it. | |
| 253 | + * | |
| 254 | + * @param ObjectInterface[] $objects | |
| 255 | + * @throws \Exception | |
| 256 | + * @return void | |
| 257 | + */ | |
| 258 | + public function add(ObjectInterface ...$objects) | |
| 259 | +    { | |
| 260 | + foreach ($objects as $object) | |
| 261 | +        { | |
| 262 | + if ($object instanceof RoleInterface) | |
| 263 | +            { | |
| 264 | + $this->addRole((string)$object); | |
| 265 | + } | |
| 266 | + else if ($object instanceof ResourceInterface) | |
| 267 | +            { | |
| 268 | + $this->addResource((string)$object); | |
| 269 | + } | |
| 270 | + else if ($object instanceof PermissionInterface) | |
| 271 | +            { | |
| 272 | + $this->addPermission((string)$object); | |
| 273 | + } | |
| 274 | +            else { | |
| 275 | + throw new \Exception( | |
| 276 | + sprintf( | |
| 277 | + "%s must implement one of RoleInterface, '. | |
| 278 | 278 | 'ResourceInterface and PermissionInterface", | 
| 279 | - $object | |
| 280 | - ) | |
| 281 | - ); | |
| 282 | - } | |
| 283 | - } | |
| 284 | - } | |
| 285 | - | |
| 286 | - /** | |
| 287 | - * Change the status option of an assigned permission to true | |
| 288 | - * | |
| 289 | - * @param string $role; | |
| 290 | - * @param string $permission | |
| 291 | - * @param string $resource | |
| 292 | - * @param boolean $status Optional | |
| 293 | - * @throws \Exception | |
| 294 | - * @return void | |
| 295 | - */ | |
| 296 | - public function allow(string $role, string $permission, string $resource, bool $status=null) | |
| 297 | -	{ | |
| 279 | + $object | |
| 280 | + ) | |
| 281 | + ); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + } | |
| 285 | + | |
| 286 | + /** | |
| 287 | + * Change the status option of an assigned permission to true | |
| 288 | + * | |
| 289 | + * @param string $role; | |
| 290 | + * @param string $permission | |
| 291 | + * @param string $resource | |
| 292 | + * @param boolean $status Optional | |
| 293 | + * @throws \Exception | |
| 294 | + * @return void | |
| 295 | + */ | |
| 296 | + public function allow(string $role, string $permission, string $resource, bool $status=null) | |
| 297 | +    { | |
| 298 | 298 | $status = $status ?? true; | 
| 299 | -		if (!$this->roleRegistry->exists($role)) { | |
| 299 | +        if (!$this->roleRegistry->exists($role)) { | |
| 300 | 300 | throw new \Exception( | 
| 301 | 301 | sprintf( | 
| 302 | 302 | "The role: %s doesnt exist", | 
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare (strict_types=1); | |
| 1 | +<?php declare (strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library | 
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare (strict_types=1); | |
| 1 | +<?php declare (strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library | 
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare (strict_types=1); | |
| 1 | +<?php declare (strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library | 
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare (strict_types=1); | |
| 1 | +<?php declare (strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library | 
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare (strict_types=1); | |
| 1 | +<?php declare (strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library | 
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare (strict_types=1); | |
| 1 | +<?php declare (strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library | 
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare (strict_types=1); | |
| 1 | +<?php declare (strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library | 
| @@ -19,10 +19,10 @@ | ||
| 19 | 19 | */ | 
| 20 | 20 | interface RoleInterface | 
| 21 | 21 |  { | 
| 22 | - /** | |
| 23 | - * Returns the descriptionof a role object | |
| 24 | - * | |
| 25 | - * @return string | |
| 26 | - */ | |
| 27 | - public function getDescription() : string; | |
| 22 | + /** | |
| 23 | + * Returns the descriptionof a role object | |
| 24 | + * | |
| 25 | + * @return string | |
| 26 | + */ | |
| 27 | + public function getDescription() : string; | |
| 28 | 28 | } | 
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare (strict_types=1); | |
| 1 | +<?php declare (strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | /** | 
| 4 | 4 | * This file is part of the Samshal\Acl library |