| Conditions | 1 |
| Paths | 1 |
| Total Lines | 69 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| 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 namespace Anomaly\UsersModule; |
||
| 31 | public function getFunctions() |
||
| 32 | { |
||
| 33 | return [ |
||
| 34 | new \Twig_SimpleFunction( |
||
| 35 | 'user_has_role', |
||
| 36 | function ($identifier) { |
||
| 37 | return $this->dispatch(new CheckUserRole($identifier)); |
||
| 38 | } |
||
| 39 | ), |
||
| 40 | new \Twig_SimpleFunction( |
||
| 41 | 'user_has_permission', |
||
| 42 | function ($permission) { |
||
| 43 | return $this->dispatch(new CheckUserPermission($permission)); |
||
| 44 | } |
||
| 45 | ), |
||
| 46 | new \Twig_SimpleFunction( |
||
| 47 | 'login_form', |
||
| 48 | function (array $parameters = []) { |
||
| 49 | return $this->dispatch(new BuildLoginForm($parameters)); |
||
| 50 | }, |
||
| 51 | ['is_safe' => ['html']] |
||
| 52 | ), |
||
| 53 | new \Twig_SimpleFunction( |
||
| 54 | 'register_form', |
||
| 55 | function (array $parameters = []) { |
||
| 56 | return $this->dispatch(new BuildRegisterForm($parameters)); |
||
| 57 | }, |
||
| 58 | ['is_safe' => ['html']] |
||
| 59 | ), |
||
| 60 | new \Twig_SimpleFunction( |
||
| 61 | 'reset_form', |
||
| 62 | function (array $parameters = []) { |
||
| 63 | return $this->dispatch(new BuildResetForm($parameters)); |
||
| 64 | }, |
||
| 65 | ['is_safe' => ['html']] |
||
| 66 | ), |
||
| 67 | new \Twig_SimpleFunction( |
||
| 68 | 'complete_reset_form', |
||
| 69 | function (array $parameters = []) { |
||
| 70 | return $this->dispatch(new BuildCompleteResetForm($parameters)); |
||
| 71 | }, |
||
| 72 | ['is_safe' => ['html']] |
||
| 73 | ), |
||
| 74 | new \Twig_SimpleFunction( |
||
| 75 | 'login_path', |
||
| 76 | function () { |
||
| 77 | return $this->dispatch(new GetLoginPath()); |
||
| 78 | } |
||
| 79 | ), |
||
| 80 | new \Twig_SimpleFunction( |
||
| 81 | 'logout_path', |
||
| 82 | function ($redirect = null) { |
||
| 83 | return $this->dispatch(new GetLogoutPath($redirect)); |
||
| 84 | } |
||
| 85 | ), |
||
| 86 | new \Twig_SimpleFunction( |
||
| 87 | 'activate_path', |
||
| 88 | function (UserInterface $user) { |
||
| 89 | return $this->dispatch(new GetActivatePath($user)); |
||
| 90 | } |
||
| 91 | ), |
||
| 92 | new \Twig_SimpleFunction( |
||
| 93 | 'complete_reset_path', |
||
| 94 | function (UserInterface $user) { |
||
| 95 | return $this->dispatch(new GetCompleteResetPath($user)); |
||
| 96 | } |
||
| 97 | ) |
||
| 98 | ]; |
||
| 99 | } |
||
| 100 | } |
||
| 101 |