| Conditions | 1 |
| Paths | 1 |
| Total Lines | 62 |
| Code Lines | 30 |
| 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 |
||
| 64 | public function register() |
||
| 65 | { |
||
| 66 | $jaxon = app()->make(Jaxon::class); |
||
| 67 | |||
| 68 | $this->reportable(function (Throwable $e) { |
||
| 69 | // |
||
| 70 | }); |
||
| 71 | |||
| 72 | // Redirect to the login page |
||
| 73 | $this->renderable(function (AuthenticationException $e) use($jaxon) { |
||
| 74 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 75 | $ajaxResponse->redirect(route('login')); |
||
| 76 | |||
| 77 | return $jaxon->httpResponse(); |
||
| 78 | }); |
||
| 79 | |||
| 80 | // Show the error message in a dialog |
||
| 81 | $this->renderable(function (MessageException $e) use($jaxon) { |
||
| 82 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 83 | $ajaxResponse->dialog->error($e->getMessage(), trans('common.titles.error')); |
||
| 84 | |||
| 85 | return $jaxon->httpResponse(); |
||
| 86 | }); |
||
| 87 | |||
| 88 | // Show the warning message in a dialog, and show the sessions page. |
||
| 89 | $this->renderable(function (PlanningRoundException $e) use($jaxon) { |
||
| 90 | $jaxon->cl(Round::class)->home(); |
||
| 91 | |||
| 92 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 93 | $ajaxResponse->dialog->warning($e->getMessage(), trans('common.titles.warning')); |
||
| 94 | |||
| 95 | return $jaxon->httpResponse(); |
||
| 96 | }); |
||
| 97 | |||
| 98 | // Show the warning message in a dialog, and show the pools page. |
||
| 99 | $this->renderable(function (PlanningPoolException $e) use($jaxon) { |
||
| 100 | $jaxon->cl(Pool::class)->home(); |
||
| 101 | |||
| 102 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 103 | $ajaxResponse->dialog->warning($e->getMessage(), trans('common.titles.warning')); |
||
| 104 | |||
| 105 | return $jaxon->httpResponse(); |
||
| 106 | }); |
||
| 107 | |||
| 108 | // Show the warning message in a dialog, and show the members page. |
||
| 109 | $this->renderable(function (TontineMemberException $e) use($jaxon) { |
||
| 110 | $jaxon->cl(Member::class)->home(); |
||
| 111 | |||
| 112 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 113 | $ajaxResponse->dialog->warning($e->getMessage(), trans('common.titles.warning')); |
||
| 114 | |||
| 115 | return $jaxon->httpResponse(); |
||
| 116 | }); |
||
| 117 | |||
| 118 | // Show the warning message in a dialog, and show the sessions page. |
||
| 119 | $this->renderable(function (MeetingRoundException $e) use($jaxon) { |
||
| 120 | $jaxon->cl(Session::class)->home(); |
||
| 121 | |||
| 122 | $ajaxResponse = $jaxon->ajaxResponse(); |
||
| 123 | $ajaxResponse->dialog->warning($e->getMessage(), trans('common.titles.warning')); |
||
| 124 | |||
| 125 | return $jaxon->httpResponse(); |
||
| 126 | }); |
||
| 129 |