| Conditions | 18 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 40 |
| 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 |
||
| 15 | public function boot() |
||
| 16 | { |
||
| 17 | FormFacade::component('bsText', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'text']); |
||
| 18 | FormFacade::component('bsEmail', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'email']); |
||
| 19 | FormFacade::component('bsTel', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'tel']); |
||
| 20 | FormFacade::component('bsNumber', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'number']); |
||
| 21 | FormFacade::component('bsDatetime', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'datetime']); |
||
| 22 | FormFacade::component('bsPassword', 'components.form.input', ['name', 'attributes' => [], 'value' => '', 'type' => 'password']); |
||
| 23 | FormFacade::component('bsFile', 'components.form.input', ['name', 'attributes' => [], 'value' => null, 'type' => 'file']); |
||
| 24 | FormFacade::component('bsTextarea', 'components.form.textarea', ['name', 'value' => null, 'attributes' => []]); |
||
| 25 | FormFacade::component('bsSelect', 'components.form.select', ['name', 'list' => [], 'selected' => null, 'attributes' => []]); |
||
| 26 | FormFacade::component('bsCheckbox', 'components.form.custom-control', ['name', 'description', 'value' => null, 'type' => 'checkbox']); |
||
| 27 | HtmlFacade::macro('asset', function ($manifestName, $path) { |
||
| 28 | static $manifest; |
||
| 29 | $basePath = app()->environment('production') ? 'dist' : 'build'; |
||
|
|
|||
| 30 | if (! $manifest |
||
| 31 | && file_exists($manifestPath = public_path("{$basePath}/manifest-{$manifestName}.json")) |
||
| 32 | ) { |
||
| 33 | $manifest = json_decode(file_get_contents($manifestPath), true); |
||
| 34 | } |
||
| 35 | if ($manifest && isset($manifest[$path])) { |
||
| 36 | return $manifest[$path]; |
||
| 37 | } |
||
| 38 | }); |
||
| 39 | /* |
||
| 40 | * Prepare flash message for alerts |
||
| 41 | */ |
||
| 42 | View::composer('partials/messages', function (\Illuminate\View\View $view) { |
||
| 43 | $data = collect($view->getData()); |
||
| 44 | if ($flash = session()->get('flash_message') ?: $data->get('flashMessage')) { |
||
| 45 | $view->with('flashMessage', $flash); |
||
| 46 | $view->with('flashType', 'info'); |
||
| 47 | } elseif ($flash = session()->get('flash_success') ?: $data->get('flashSuccess')) { |
||
| 48 | $view->with('flashMessage', $flash); |
||
| 49 | $view->with('flashType', 'success'); |
||
| 50 | } elseif ($flash = session()->get('flash_info') ?: $data->get('flashInfo')) { |
||
| 51 | $view->with('flashMessage', $flash); |
||
| 52 | $view->with('flashType', 'info'); |
||
| 53 | } elseif ($flash = session()->get('flash_warning') ?: $data->get('flashWarning')) { |
||
| 54 | $view->with('flashMessage', $flash); |
||
| 55 | $view->with('flashType', 'warning'); |
||
| 56 | } elseif ($flash = session()->get('flash_danger') ?: $data->get('flashDanger')) { |
||
| 57 | $view->with('flashMessage', $flash); |
||
| 58 | $view->with('flashType', 'danger'); |
||
| 59 | } elseif ($flash = session()->get('flash_error') ?: $data->get('flashError')) { |
||
| 60 | $view->with('flashMessage', $flash); |
||
| 61 | $view->with('flashType', 'danger'); |
||
| 62 | } |
||
| 63 | }); |
||
| 64 | View::composer('*', function (\Illuminate\View\View $view) { |
||
| 65 | $view->with('loggedInUser', auth()->user()); |
||
| 66 | }); |
||
| 76 |