Conditions | 2 |
Paths | 2 |
Total Lines | 52 |
Code Lines | 32 |
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 |
||
34 | public function boot() |
||
35 | { |
||
36 | // prepend the views from the theme |
||
37 | $this->app['view']->getFinder()->prependLocation(base_path('theme/views')); |
||
38 | |||
39 | $this->loadViewsFrom(__DIR__.'/../resources/views', 'blog'); |
||
40 | $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
||
41 | $this->loadRoutesFrom(__DIR__.'/../routes/web.php'); |
||
42 | |||
43 | Flash::levels([ |
||
44 | 'success' => '', |
||
45 | 'error' => 'bg-red-500', |
||
46 | ]); |
||
47 | |||
48 | Menu::macro('blogAdminNavHeader', function () { |
||
49 | return Menu::build( |
||
50 | config('blog.navHeader'), |
||
51 | function (\Spatie\Menu\Laravel\Menu $menu, $view) { |
||
52 | $menu->add(View::create($view)->addParentClass('ml-5 lg:ml-6')); |
||
53 | }) |
||
54 | ->addClass('flex items-end lg:items-center lg:pr-2') |
||
55 | ->addItemClass('p-2') |
||
56 | ->setActiveFromRequest('/'); |
||
57 | }); |
||
58 | |||
59 | Menu::macro('blogAdminNav', function () { |
||
60 | return Menu::build( |
||
61 | config('blog.navAdmin'), |
||
62 | function (\Spatie\Menu\Laravel\Menu $menu, $view) { |
||
63 | $menu->add(View::create($view)->addParentClass('')); |
||
64 | }) |
||
65 | ->addItemClass('p-2') |
||
66 | ->setActiveFromRequest('/'); |
||
67 | }); |
||
68 | |||
69 | // register the route middleware groups |
||
70 | $this->app['router']->middlewareGroup('blog-auth', |
||
71 | [Authenticate::class]); |
||
72 | $this->app['router']->middlewareGroup('blog-nocache', |
||
73 | [NoHttpCache::class]); |
||
74 | $this->app['router']->middlewareGroup('blog-cacheResponse', |
||
75 | [CacheResponse::class]); |
||
76 | |||
77 | // router bindings |
||
78 | $this->registerRouteModelBindings(); |
||
79 | |||
80 | // model event observers |
||
81 | Post::observe(PostObserver::class); |
||
82 | |||
83 | // Publishing is only necessary when using the CLI. |
||
84 | if ($this->app->runningInConsole()) { |
||
85 | $this->bootForConsole(); |
||
86 | } |
||
165 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.