| Conditions | 3 |
| Paths | 4 |
| Total Lines | 32 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public function compose(View $view) |
||
| 16 | { |
||
| 17 | $navbarMenu = [ |
||
| 18 | [ |
||
| 19 | 'title' => 'Home Page', |
||
| 20 | 'url' => route('posts.index'), |
||
| 21 | 'active' => request()->routeIs('/') || request()->routeIs('*posts*'), |
||
| 22 | ], |
||
| 23 | [ |
||
| 24 | 'title' => 'Categories', |
||
| 25 | 'url' => route('categories.index'), |
||
| 26 | 'active' => request()->routeIs('*categories*'), |
||
| 27 | ], |
||
| 28 | [ |
||
| 29 | 'title' => 'Tags', |
||
| 30 | 'url' => route('tags.index'), |
||
| 31 | 'active' => request()->routeIs('*tags*'), |
||
| 32 | ], |
||
| 33 | ]; |
||
| 34 | |||
| 35 | if ($this->aboutMeService->hasContent()) { |
||
| 36 | $navbarMenu[] = [ |
||
| 37 | 'title' => 'About me', |
||
| 38 | 'url' => route('about-me.show'), |
||
| 39 | 'active' => request()->routeIs('about-me.show'), |
||
| 40 | ]; |
||
| 41 | } |
||
| 42 | |||
| 43 | $view->with('navbarMenu', collect($navbarMenu)->map(function ($menuElement) { |
||
| 44 | return (object) $menuElement; |
||
| 45 | })); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |
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: