Conditions | 3 |
Paths | 4 |
Total Lines | 32 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | public function compose(View $view) |
||
17 | { |
||
18 | $navbarMenu = [ |
||
19 | [ |
||
20 | 'title' => 'Home Page', |
||
21 | 'url' => route('posts.index'), |
||
22 | 'active' => request()->routeIs('/') || request()->routeIs('*posts*'), |
||
23 | ], |
||
24 | [ |
||
25 | 'title' => 'Categories', |
||
26 | 'url' => route('categories.index'), |
||
27 | 'active' => request()->routeIs('*categories*'), |
||
28 | ], |
||
29 | [ |
||
30 | 'title' => 'Tags', |
||
31 | 'url' => route('tags.index'), |
||
32 | 'active' => request()->routeIs('*tags*'), |
||
33 | ] |
||
34 | ]; |
||
35 | |||
36 | if ($this->aboutMeService->hasContent()) { |
||
37 | $navbarMenu[] = [ |
||
38 | 'title' => 'About me', |
||
39 | 'url' => route('about-me.show'), |
||
40 | 'active' => request()->routeIs('about-me.show') |
||
41 | ]; |
||
42 | } |
||
43 | |||
44 | $view->with('navbarMenu', collect($navbarMenu)->map(function ($menuElement) { |
||
45 | return (object) $menuElement; |
||
46 | })); |
||
47 | } |
||
48 | } |
||
49 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: