@@ -49,10 +49,11 @@ |
||
| 49 | 49 | * @return mixed |
| 50 | 50 | */ |
| 51 | 51 | public function __call($name, array $arguments) { |
| 52 | - if (is_callable($this->$name)) |
|
| 53 | - return call_user_func($this->$name, $arguments); |
|
| 54 | - else |
|
| 55 | - throw new \RuntimeException("Method {$name} does not exist."); |
|
| 52 | + if (is_callable($this->$name)) { |
|
| 53 | + return call_user_func($this->$name, $arguments); |
|
| 54 | + } else { |
|
| 55 | + throw new \RuntimeException("Method {$name} does not exist."); |
|
| 56 | + } |
|
| 56 | 57 | } |
| 57 | 58 | |
| 58 | 59 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * `YourNamespace\WhateverYouWant\Developer\LintPermission`. |
| 29 | 29 | * @nosubgrouping |
| 30 | 30 | */ |
| 31 | -interface IRole { |
|
| 31 | +interface IRole { |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | * @param[in] integer $offset The offset to retrieve. |
| 109 | 109 | * @retval mixed Can return all value types. |
| 110 | 110 | */ |
| 111 | - public function offsetGet($offset) { |
|
| 111 | + public function offsetGet($offset) { |
|
| 112 | 112 | return $this->meta[$this->name][$offset]; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -46,8 +46,9 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function grant(IRole $role) { |
| 48 | 48 | // Checks if the same role has been already assigned to the member. |
| 49 | - if ($this->exists($role)) |
|
| 50 | - return; |
|
| 49 | + if ($this->exists($role)) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | 53 | $roles = $this->meta[$this->name]; |
| 53 | 54 | |
@@ -57,8 +58,7 @@ discard block |
||
| 57 | 58 | // If a subclass of `$role` exists for the current collection then the function returns, because a more |
| 58 | 59 | // important role has been already assigned to the member. |
| 59 | 60 | return; |
| 60 | - } |
|
| 61 | - elseif (is_subclass_of($role, $class, FALSE)) { |
|
| 61 | + } elseif (is_subclass_of($role, $class, FALSE)) { |
|
| 62 | 62 | // If `$role` is an instance of a subclass of any role previously assigned to the member that means the new role |
| 63 | 63 | // is more important and the one already assigned must be removed. |
| 64 | 64 | unset($this->meta[$this->name][$name]); |
@@ -76,8 +76,9 @@ discard block |
||
| 76 | 76 | * @param[in] IRole $role A role object. |
| 77 | 77 | */ |
| 78 | 78 | public function revoke(IRole $role) { |
| 79 | - if ($this->exists($role)) |
|
| 80 | - unset($this->meta[$this->name][$role->getName()]); |
|
| 79 | + if ($this->exists($role)) { |
|
| 80 | + unset($this->meta[$this->name][$role->getName()]); |
|
| 81 | + } |
|
| 81 | 82 | } |
| 82 | 83 | |
| 83 | 84 | |
@@ -57,9 +57,9 @@ |
||
| 57 | 57 | |
| 58 | 58 | // Invokes the method. |
| 59 | 59 | return $method->invoke($permission); |
| 60 | + } else { |
|
| 61 | + return FALSE; |
|
| 60 | 62 | } |
| 61 | - else |
|
| 62 | - return FALSE; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -72,16 +72,17 @@ |
||
| 72 | 72 | |
| 73 | 73 | // Exits from the do while and foreach as well. |
| 74 | 74 | break 2; |
| 75 | - } |
|
| 76 | - else { |
|
| 75 | + } else { |
|
| 77 | 76 | // Go back to the previous role class in the hierarchy. For example, from AdminRole to ModeratorRole. |
| 78 | 77 | $parentRoleReflection = $roleReflection->getParentClass(); |
| 79 | 78 | |
| 80 | 79 | // Proceed only if the parent role is not an abstract class. |
| 81 | - if (is_object($parentRoleReflection) && !$parentRoleReflection->isAbstract()) |
|
| 82 | - $roleClass = $parentRoleReflection->name; |
|
| 83 | - else |
|
| 84 | - break; // No more roles in the hierarchy. |
|
| 80 | + if (is_object($parentRoleReflection) && !$parentRoleReflection->isAbstract()) { |
|
| 81 | + $roleClass = $parentRoleReflection->name; |
|
| 82 | + } else { |
|
| 83 | + break; |
|
| 84 | + } |
|
| 85 | + // No more roles in the hierarchy. |
|
| 85 | 86 | } |
| 86 | 87 | } while (TRUE); |
| 87 | 88 | |