| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 81 | public function register() |
||
| 82 | { |
||
| 83 | $this->reportable(function (Throwable $e) { |
||
| 84 | // |
||
| 85 | }); |
||
| 86 | |||
| 87 | // Redirect to the login page |
||
| 88 | $this->renderable(function (AuthenticationException $e) { |
||
| 89 | $jaxon = app()->make(Jaxon::class); |
||
| 90 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 91 | $ajaxResponse->redirect(route('login')); |
||
| 92 | |||
| 93 | return $jaxon->httpResponse(); |
||
| 94 | }); |
||
| 95 | |||
| 96 | // Show the error message in a dialog |
||
| 97 | $this->renderable(function (MessageException $e) { |
||
| 98 | $jaxon = app()->make(Jaxon::class); |
||
| 99 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 100 | $ajaxResponse->dialog->error($e->getMessage(), trans('common.titles.error')); |
||
| 101 | |||
| 102 | return $jaxon->httpResponse(); |
||
| 103 | }); |
||
| 104 | |||
| 105 | // Show the warning message in a dialog |
||
| 106 | $this->renderable(function (PlanningRoundException $e) { |
||
| 107 | $this->getCallableObject(Round::class)->home(); |
||
| 108 | |||
| 109 | $jaxon = app()->make(Jaxon::class); |
||
| 110 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 111 | $ajaxResponse->dialog->warning($e->getMessage(), trans('common.titles.warning')); |
||
| 112 | |||
| 113 | return $jaxon->httpResponse(); |
||
| 114 | }); |
||
| 115 | |||
| 116 | // Show the warning message in a dialog |
||
| 117 | $this->renderable(function (PlanningPoolException $e) { |
||
| 118 | $this->getCallableObject(Pool::class)->home(); |
||
| 119 | |||
| 120 | $jaxon = app()->make(Jaxon::class); |
||
| 121 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 122 | $ajaxResponse->dialog->warning($e->getMessage(), trans('common.titles.warning')); |
||
| 123 | |||
| 124 | return $jaxon->httpResponse(); |
||
| 125 | }); |
||
| 126 | |||
| 127 | // Show the warning message in a dialog |
||
| 128 | $this->renderable(function (TontineMemberException $e) { |
||
| 129 | $this->getCallableObject(Member::class)->home(); |
||
| 130 | |||
| 131 | $jaxon = app()->make(Jaxon::class); |
||
| 132 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 133 | $ajaxResponse->dialog->warning($e->getMessage(), trans('common.titles.warning')); |
||
| 134 | |||
| 135 | return $jaxon->httpResponse(); |
||
| 136 | }); |
||
| 139 |