| Conditions | 7 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 25 |
| 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 |
||
| 33 | public function registerRbacPolicies() |
||
| 34 | { |
||
| 35 | /* |
||
| 36 | |-------------------------------------------------------------------------- |
||
| 37 | | ADMIN member section. |
||
| 38 | |-------------------------------------------------------------------------- |
||
| 39 | */ |
||
| 40 | Gate::define(Permission::ADMINISTRATE_PERMISSION, function (RbacUserInterface $user) { |
||
| 41 | return $user->hasAccess([ |
||
| 42 | Permission::ADMINISTRATE_PERMISSION |
||
| 43 | ]); |
||
| 44 | }); |
||
| 45 | |||
| 46 | Gate::define(Permission::ASSIGN_ROLE_FLAG, function (RbacUserInterface $user, MemberToRole $memberToRole) { |
||
| 47 | return $user->canAssignRole($memberToRole->getMember(), $memberToRole->getRole()); |
||
| 48 | }); |
||
| 49 | |||
| 50 | Gate::define(Permission::DELETE_MEMBER_FLAG, function (RbacUserInterface $user, $memberKey) { |
||
| 51 | return $user->getMemberKeyAttribute() != $memberKey; |
||
| 52 | }); |
||
| 53 | |||
| 54 | |||
| 55 | /* |
||
| 56 | |-------------------------------------------------------------------------- |
||
| 57 | | Record section for application. |
||
| 58 | |-------------------------------------------------------------------------- |
||
| 59 | */ |
||
| 60 | Gate::define(Permission::VIEW_RECORD_PERMISSION, function (RbacUserInterface $user, RbacModelInterface $model = null) { |
||
| 61 | return $user->hasAccess([ |
||
| 62 | Permission::VIEW_RECORD_PERMISSION |
||
| 63 | ]) || !empty($model) ? $user->getMemberKeyAttribute() == $model->getAuthorIdAttribute() : false; |
||
|
|
|||
| 64 | }); |
||
| 65 | |||
| 66 | Gate::define(Permission::CREATE_RECORD_PERMISSION, function (RbacUserInterface $user) { |
||
| 67 | return $user->hasAccess([ |
||
| 68 | Permission::CREATE_RECORD_PERMISSION |
||
| 69 | ]); |
||
| 70 | }); |
||
| 71 | |||
| 72 | Gate::define(Permission::UPDATE_RECORD_PERMISSION, function (RbacUserInterface $user, RbacModelInterface $model = null) { |
||
| 73 | return $user->hasAccess([ |
||
| 74 | Permission::UPDATE_RECORD_PERMISSION |
||
| 75 | ]) || !empty($model) ? $user->getMemberKeyAttribute() == $model->getAuthorIdAttribute() : false; |
||
| 76 | }); |
||
| 77 | |||
| 78 | Gate::define(Permission::DELETE_RECORD_PERMISSION, function (RbacUserInterface $user, RbacModelInterface $model = null) { |
||
| 79 | return $user->hasAccess([ |
||
| 80 | Permission::DELETE_RECORD_PERMISSION |
||
| 81 | ]) || !empty($model) ? $user->getMemberKeyAttribute() == $model->getAuthorIdAttribute() : false; |
||
| 82 | }); |
||
| 83 | |||
| 84 | Gate::define(Permission::PUBLISH_RECORD_PERMISSION, function (RbacUserInterface $user) { |
||
| 85 | return $user->hasAccess([ |
||
| 86 | Permission::PUBLISH_RECORD_PERMISSION |
||
| 87 | ]); |
||
| 91 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.