Conditions | 3 |
Paths | 2 |
Total Lines | 69 |
Code Lines | 44 |
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 |
||
12 | public function boot(): void |
||
13 | { |
||
14 | $this->loadViewsFrom(__DIR__.'/../../resources/views', 'chief'); |
||
15 | |||
16 | $this->app['view']->addNamespace('chief-fragments', __DIR__.'/../../src/Fragments/resources'); |
||
17 | |||
18 | View::composer([ |
||
19 | 'chief::manager._transitions.modals.archive-modal', |
||
20 | ], function ($view) { |
||
21 | $viewData = $view->getData(); |
||
22 | |||
23 | $ignoredModel = (isset($viewData['model'])) |
||
24 | ? $viewData['model'] |
||
25 | : null; |
||
26 | |||
27 | $onlineModels = UrlHelper::allOnlineModels(false, $ignoredModel); |
||
28 | $view->with('targetModels', $onlineModels); |
||
29 | }); |
||
30 | |||
31 | Blade::componentNamespace('Thinktomorrow\\Chief\\App\\View\\Components', 'chief'); |
||
32 | Blade::component('chief::manager.windows.status.window', 'chief::window.status'); |
||
33 | Blade::component('chief::manager.windows.links.window', 'chief::window.links'); |
||
34 | |||
35 | // Chief components |
||
36 | Blade::component('chief::components.title', 'chief-title'); |
||
37 | Blade::component('chief::components.content', 'chief-content'); |
||
38 | Blade::component('chief::components.sidebar', 'chief-sidebar'); |
||
39 | Blade::component('chief::components.inline-notification', 'chief-inline-notification'); |
||
40 | Blade::component('chief::components.icon-label', 'chief-icon-label'); |
||
41 | Blade::component('chief::components.icon-button', 'chief-icon-button'); |
||
42 | Blade::component('chief::components.hierarchy', 'chief-hierarchy'); |
||
43 | Blade::component('chief::components.nav-item', 'chief::nav.item'); |
||
44 | |||
45 | // Wireframe components |
||
46 | Blade::component('chief::wireframes.wireframe', 'wireframe'); |
||
47 | Blade::component('chief::wireframes.container', 'wireframe-container'); |
||
48 | Blade::component('chief::wireframes.row', 'wireframe-row'); |
||
49 | Blade::component('chief::wireframes.column', 'wireframe-column'); |
||
50 | Blade::component('chief::wireframes.title', 'wireframe-title'); |
||
51 | Blade::component('chief::wireframes.text', 'wireframe-text'); |
||
52 | Blade::component('chief::wireframes.image', 'wireframe-image'); |
||
53 | Blade::component('chief::wireframes.video', 'wireframe-video'); |
||
54 | Blade::component('chief::wireframes.rect', 'wireframe-rect'); |
||
55 | |||
56 | // Chief directives |
||
57 | |||
58 | Blade::directive('adminRoute', function ($expression) { |
||
59 | return "<?php echo \$manager->route({$expression}); ?>"; |
||
60 | }); |
||
61 | |||
62 | Blade::directive('adminCan', function ($expression) { |
||
63 | return "<?php if (\$manager->can({$expression})) { ?>"; |
||
64 | }); |
||
65 | |||
66 | Blade::directive('elseAdminCan', function () { |
||
67 | return '<?php } else { ?>'; |
||
68 | }); |
||
69 | |||
70 | Blade::directive('endAdminCan', function () { |
||
71 | return '<?php } ?>'; |
||
72 | }); |
||
73 | |||
74 | // TODO(ben): better solution for this ugly mess |
||
75 | // Hello Tijs. We meet again |
||
76 | $isCollapsedOnPageLoad = |
||
77 | isset($_COOKIE['is-navigation-collapsed']) |
||
78 | ? filter_var($_COOKIE['is-navigation-collapsed'], FILTER_VALIDATE_BOOLEAN) |
||
79 | : false; |
||
80 | view()->share('isCollapsedOnPageLoad', $isCollapsedOnPageLoad); |
||
81 | } |
||
87 |