Conditions | 9 |
Paths | 17 |
Total Lines | 59 |
Code Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
59 | protected function addLinks() |
||
60 | { |
||
61 | $this->content['header']['sidebar'] = array(); |
||
62 | if($this->user === false || $this->user === null) |
||
63 | { |
||
64 | return; |
||
65 | } |
||
66 | $this->content['header']['sidebar']['Dashboard'] = array('icon' => 'fa-tachometer-alt', 'url' => 'index.php'); |
||
67 | if($this->isLead === false) |
||
68 | { |
||
69 | $this->content['header']['sidebar']['Events'] = array('icon' => 'fa-calendar-alt', 'url' => 'events.php'); |
||
70 | $this->content['header']['sidebar']['Departments'] = array('icon' => 'fa-building', 'url' => 'departments.php'); |
||
71 | } |
||
72 | $charts_menu = array( |
||
73 | 'Shift Schedules' => 'shift_schedules.php', |
||
74 | 'Shift Stats' => 'shift_stats.php', |
||
75 | 'T-Shirts' => 'tshirts.php', |
||
76 | 'Participant Shifts' => 'vol_shifts.php', |
||
77 | 'Volunteers without Shifts' => 'no_shifts.php', |
||
78 | 'Empty Shifts' => 'report_empty_shifts.php', |
||
79 | 'Early Entry' => 'report_early_entry.php' |
||
80 | ); |
||
81 | $shifts_menu = array( |
||
82 | 'Add/Edit Shifts' => 'shifts.php', |
||
83 | 'Pending Shifts' => 'pending.php', |
||
84 | 'Early Entry/Late Stay Approval' => 'ee.php' |
||
85 | ); |
||
86 | $certApprovalCount = 0; |
||
87 | $certTable = \DataSetFactory::getDataTableByNames('fvs', 'certifications'); |
||
88 | $userTable = \DataSetFactory::getDataTableByNames('fvs', 'participants'); |
||
89 | $certs = $certTable->read(); |
||
90 | if($certs !== false) |
||
91 | { |
||
92 | $count = count($certs); |
||
|
|||
93 | for($i = 0; $i < $count; $i++) |
||
94 | { |
||
95 | $filter = new \Data\Filter('certs.'.$certs[$i]['certID'].'.status eq pending'); |
||
96 | $users = $userTable->read($filter); |
||
97 | $certApprovalCount += count($users); |
||
98 | } |
||
99 | } |
||
100 | $certBadge = ''; |
||
101 | if($certApprovalCount > 0) |
||
102 | { |
||
103 | $certBadge = '<span class="badge badge-secondary">'.$certApprovalCount.'</span>'; |
||
104 | } |
||
105 | $this->content['header']['sidebar']['Roles'] = array('icon' => 'fa-address-card', 'url' => 'roles.php'); |
||
106 | $this->content['header']['sidebar']['Shifts'] = array('icon' => 'fa-tshirt', 'menu' => $shifts_menu); |
||
107 | $this->content['header']['sidebar']['Volunteers'] = array('icon' => 'fa-user', 'url' => 'volunteers.php'); |
||
108 | $this->content['header']['sidebar']['Certification Approval '.$certBadge] = array('icon' => 'fa-stamp', 'url' => 'cert_approval.php'); |
||
109 | $this->content['header']['sidebar']['Reports'] = array('icon' => 'fa-chart-bar', 'menu' => $charts_menu); |
||
110 | $this->content['header']['sidebar']['Contact'] = array('icon' => 'fa-envelope', 'url' => 'contact.php'); |
||
111 | if($this->user && $this->user->isInGroupNamed('VolunteerAdmins')) |
||
112 | { |
||
113 | $admin_menu = array( |
||
114 | 'Email Text' => 'emails.php', |
||
115 | 'Certifications' => 'certs.php' |
||
116 | ); |
||
117 | $this->content['header']['sidebar']['Admin'] = array('icon' => 'fa-cog', 'menu' => $admin_menu); |
||
118 | } |
||
122 |