| Conditions | 6 | 
| Paths | 5 | 
| Total Lines | 65 | 
| Code Lines | 42 | 
| 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 | ||
| 24 | protected function init(): void | ||
| 25 | 	{		 | ||
| 26 | parent::init(); | ||
| 27 | |||
| 28 | $this->entries = collect(); | ||
| 29 | |||
| 30 | $this->tools = collect(); | ||
| 31 | |||
| 32 | // credits | ||
| 33 | 		$this->addItem(__(':epesi powered version :version', [ | ||
| 34 | 				'epesi' => config('epesi.ui.credit.title', 'EPESI'),  | ||
| 35 | 'version' => $this->getApp()->version | ||
| 36 | 		]))->setStyle('font-size', '80%')->link(config('epesi.ui.credit.link')); | ||
| 37 | |||
| 38 | // global search | ||
| 39 | $this->addItem()->add(new Input([ | ||
| 40 | 				'placeholder' => 'Search ' . config('epesi.ui.title', 'EPESI'), | ||
| 41 | 'icon' => 'search' | ||
| 42 | 		]))->addClass('transparent'); | ||
|  | |||
| 43 | |||
| 44 | // $messageMenu = $this->menuRight->addMenu(['', 'icon' => 'envelope outline']); | ||
| 45 | |||
| 46 | $this->addItem([ | ||
| 47 | 'icon' => 'th' | ||
| 48 | ], Launchpad::addTo($this)->getJsModal()); | ||
| 49 | |||
| 50 | 		foreach(UserMenuJoint::collect() as $joint) { | ||
| 51 | 			foreach ($joint->tools()?: [] as $tool) { | ||
| 52 | $this->addTool($tool); | ||
| 53 | } | ||
| 54 | |||
| 55 | 			foreach ($joint->entries()?: [] as $entry) { | ||
| 56 | $this->addEntry($entry); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | $this->userMenu = $this->addMenu([ | ||
| 61 | $this->getUserMenuLabel(), | ||
| 62 | 'icon' => 'user' | ||
| 63 | ]); | ||
| 64 | |||
| 65 | $this->addEntry(['Perspective', 'icon' => 'users']); | ||
| 66 | $this->addEntry(['My Contact', 'icon' => 'contact']); | ||
| 67 | $this->addEntry(['My Company', 'icon' => 'users']); | ||
| 68 | |||
| 69 | $this->addEntry([ | ||
| 70 | 				'item' => ['Logout', 'icon' => 'sign out', 'attr' => ['onclick' => "event.preventDefault();$('#logout-form').submit();"]], | ||
| 71 | 				'action' => url('logout'),  | ||
| 72 | 'group' => '10000:user', | ||
| 73 | 				'callback' => function ($item) { | ||
| 74 | $logoutForm = View::addTo($item, [ | ||
| 75 | 'id' => 'logout-form', | ||
| 76 | 'attr' => [ | ||
| 77 | 'method' => 'POST', | ||
| 78 | 									'action' => url('logout'), | ||
| 79 | ], | ||
| 80 | 					])->setElement('form')->addStyle(['display' => 'none']); | ||
| 81 | |||
| 82 | View::addTo($logoutForm, [ | ||
| 83 | 'attr' => [ | ||
| 84 | 'type' => 'hidden', | ||
| 85 | 'name' => '_token', | ||
| 86 | 'value' => csrf_token(), | ||
| 87 | ], | ||
| 88 | 					])->setElement('input'); | ||
| 89 | }, | ||
| 143 | } |