| Conditions | 11 |
| Paths | 15 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 68 | public function allows(SecurityConfiguration $config, User $user) |
||
| 69 | { |
||
| 70 | if ($config->requiresIdentifiedUser() && !$user->isCommunityUser() && !$user->isIdentified($this->identificationVerifier)) { |
||
| 71 | return false; |
||
| 72 | } |
||
| 73 | |||
| 74 | try { |
||
| 75 | $allowed = $this->test($config->getAdmin(), $user->isAdmin()) |
||
| 76 | || $this->test($config->getUser(), $user->isUser()) |
||
| 77 | || $this->test($config->getCommunity(), $user->isCommunityUser()) |
||
| 78 | || $this->test($config->getSuspended(), $user->isSuspended()) |
||
| 79 | || $this->test($config->getDeclined(), $user->isDeclined()) |
||
| 80 | || $this->test($config->getNew(), $user->isNew()) |
||
| 81 | || $this->test($config->getCheckuser(), $user->isCheckuser()); |
||
| 82 | |||
| 83 | return $allowed; |
||
| 84 | } |
||
| 85 | catch (AccessDeniedException $ex) { |
||
| 86 | // something is set to deny. |
||
| 87 | return false; |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |