| Conditions | 1 |
| Paths | 1 |
| Total Lines | 144 |
| Code Lines | 103 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| 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 |
||
| 112 | public function configureMenuItems(): iterable |
||
| 113 | { |
||
| 114 | /* Menu items for payment orders menu */ |
||
| 115 | |||
| 116 | $mathematically_checking = MenuItem::linkToCrud('payment_order.mathematically_checking_needed', '', PaymentOrder::class) |
||
| 117 | ->setDefaultSort([ |
||
| 118 | 'creation_date' => 'ASC', |
||
| 119 | ]); |
||
| 120 | $this->addFiltersToMenuItem($mathematically_checking, [ |
||
| 121 | 'mathematically_correct' => 0, |
||
| 122 | 'confirmed' => 1, |
||
| 123 | ]); |
||
| 124 | |||
| 125 | $ready_for_export_section = MenuItem::linkToCrud('payment_order.ready_for_export.section', '', PaymentOrder::class) |
||
| 126 | ->setDefaultSort([ |
||
| 127 | 'creation_date' => 'ASC', |
||
| 128 | ]); |
||
| 129 | $this->addFiltersToMenuItem($ready_for_export_section, [ |
||
| 130 | 'mathematically_correct' => 1, |
||
| 131 | 'exported' => 0, |
||
| 132 | 'confirmed' => 1, |
||
| 133 | ]); |
||
| 134 | |||
| 135 | $factually_checking_fsr = MenuItem::linkToCrud('payment_order.factually_checking_needed.fsr', '', PaymentOrder::class) |
||
| 136 | ->setDefaultSort([ |
||
| 137 | 'creation_date' => 'ASC', |
||
| 138 | ]); |
||
| 139 | $this->addFiltersToMenuItem($factually_checking_fsr, [ |
||
| 140 | 'factually_correct' => 0, |
||
| 141 | 'department_type' => 'fsr', |
||
| 142 | 'exported' => 1, |
||
| 143 | 'confirmed' => 1, |
||
| 144 | ]); |
||
| 145 | |||
| 146 | $factually_checking_section = MenuItem::linkToCrud('payment_order.factually_checking_needed.section', '', PaymentOrder::class) |
||
| 147 | ->setDefaultSort([ |
||
| 148 | 'creation_date' => 'ASC', |
||
| 149 | ]); |
||
| 150 | $this->addFiltersToMenuItem($factually_checking_section, [ |
||
| 151 | 'factually_correct' => 0, |
||
| 152 | 'department_type' => 'section_misc', |
||
| 153 | 'exported' => 1, |
||
| 154 | 'confirmed' => 1, |
||
| 155 | ]); |
||
| 156 | |||
| 157 | $finished = MenuItem::linkToCrud('payment_order.finished', '', PaymentOrder::class) |
||
| 158 | ->setDefaultSort([ |
||
| 159 | 'creation_date' => 'DESC', |
||
| 160 | ]); |
||
| 161 | $this->addFiltersToMenuItem($finished, [ |
||
| 162 | 'factually_correct' => 1, |
||
| 163 | 'mathematically_correct' => 1, |
||
| 164 | 'exported' => 1, |
||
| 165 | 'confirmed' => 1, |
||
| 166 | ]); |
||
| 167 | |||
| 168 | $unconfirmed = MenuItem::linkToCrud('payment_order.unconfirmed', '', PaymentOrder::class) |
||
| 169 | ->setDefaultSort([ |
||
| 170 | 'creation_date' => 'ASC', |
||
| 171 | ]); |
||
| 172 | $this->addFiltersToMenuItem($unconfirmed, [ |
||
| 173 | 'confirmed' => 0, |
||
| 174 | ]); |
||
| 175 | |||
| 176 | $items = [ |
||
| 177 | $mathematically_checking, |
||
| 178 | $ready_for_export_section, |
||
| 179 | $factually_checking_fsr, |
||
| 180 | $factually_checking_section, |
||
| 181 | $finished, |
||
| 182 | $unconfirmed, |
||
| 183 | MenuItem::linkToCrud('payment_order.all', '', PaymentOrder::class), |
||
| 184 | ]; |
||
| 185 | |||
| 186 | /* Menu items for accountancy firm menu */ |
||
| 187 | $accountancy_exported_this_month = MenuItem::linkToCrud('accountancy_firm_menu.exported_this_month', '', PaymentOrder::class); |
||
| 188 | $this->addFiltersToMenuItem($accountancy_exported_this_month, [ |
||
| 189 | 'references_exported' => false, |
||
| 190 | 'factually_correct' => true, |
||
| 191 | 'booking_date' => [ |
||
| 192 | 'comparison' => 'between', |
||
| 193 | 'value' => (new \DateTime('first day of this month'))->setTime(0, 0, 0) |
||
| 194 | ->format(self::FILTER_DATETIME_FORMAT), |
||
| 195 | 'value2' => (new \DateTime('last day of this month'))->setTime(23, 59, 59) |
||
| 196 | ->format(self::FILTER_DATETIME_FORMAT), |
||
| 197 | ], |
||
| 198 | ]); |
||
| 199 | |||
| 200 | /* Menu items for accountancy firm menu */ |
||
| 201 | $accountancy_exported_last_month = MenuItem::linkToCrud('accountancy_firm_menu.exported_last_month', '', PaymentOrder::class); |
||
| 202 | $this->addFiltersToMenuItem($accountancy_exported_last_month, [ |
||
| 203 | 'references_exported' => false, |
||
| 204 | 'factually_correct' => true, |
||
| 205 | 'booking_date' => [ |
||
| 206 | 'comparison' => 'between', |
||
| 207 | 'value' => (new \DateTime('first day of last month'))->setTime(0, 0, 0) |
||
| 208 | ->format(self::FILTER_DATETIME_FORMAT), |
||
| 209 | 'value2' => (new \DateTime('last day of last month'))->setTime(23, 59, 59) |
||
| 210 | ->format(self::FILTER_DATETIME_FORMAT), |
||
| 211 | ], |
||
| 212 | ]); |
||
| 213 | |||
| 214 | $accountancy_exported = MenuItem::linkToCrud('accountancy_firm_menu.exported', '', PaymentOrder::class); |
||
| 215 | $this->addFiltersToMenuItem($accountancy_exported, [ |
||
| 216 | 'references_exported' => true, |
||
| 217 | 'factually_correct' => true, |
||
| 218 | ]); |
||
| 219 | |||
| 220 | $accountancy_not_exported_all = MenuItem::linkToCrud('accountancy_firm_menu.not_exported.all', '', PaymentOrder::class); |
||
| 221 | $this->addFiltersToMenuItem($accountancy_not_exported_all, [ |
||
| 222 | 'references_exported' => false, |
||
| 223 | ]); |
||
| 224 | |||
| 225 | yield MenuItem::subMenu('accountancy_firm_menu.label', 'fas fa-balance-scale') |
||
| 226 | ->setPermission('ROLE_EXPORT_REFERENCES') |
||
| 227 | ->setSubItems([ |
||
| 228 | MenuItem::section('accountancy_firm_menu.references', 'fas fa-file-download'), |
||
| 229 | $accountancy_exported_this_month, |
||
| 230 | $accountancy_exported_last_month, |
||
| 231 | $accountancy_not_exported_all, |
||
| 232 | $accountancy_exported, |
||
| 233 | ]); |
||
| 234 | |||
| 235 | yield MenuItem::subMenu('payment_order.labelp', 'fas fa-file-invoice-dollar') |
||
| 236 | ->setPermission('ROLE_SHOW_PAYMENT_ORDERS') |
||
| 237 | ->setSubItems($items); |
||
| 238 | |||
| 239 | yield MenuItem::linkToCrud('sepa_export.labelp', 'fas fa-money-check-alt', SEPAExport::class) |
||
| 240 | ->setPermission('ROLE_SHOW_SEPA_EXPORTS'); |
||
| 241 | |||
| 242 | yield MenuItem::linkToCrud('department.labelp', 'fas fa-sitemap', Department::class) |
||
| 243 | ->setPermission('ROLE_READ_ORGANISATIONS'); |
||
| 244 | yield MenuItem::linkToCrud('bank_account.labelp', 'fas fa-university', BankAccount::class) |
||
| 245 | ->setPermission('ROLE_READ_BANK_ACCOUNTS'); |
||
| 246 | yield MenuItem::linkToCrud('user.labelp', 'fas fa-user', User::class) |
||
| 247 | ->setPermission('ROLE_READ_USER'); |
||
| 248 | |||
| 249 | $version = $this->app_version.'-'.$this->gitVersionInfo->getGitCommitHash() ?? ''; |
||
| 250 | yield MenuItem::section('Version '.$version, 'fas fa-info'); |
||
| 251 | yield MenuItem::linktoRoute('dashboard.menu.audits', 'fas fa-binoculars', 'dh_auditor_list_audits') |
||
| 252 | ->setPermission('ROLE_VIEW_AUDITS'); |
||
| 253 | yield MenuItem::linktoRoute('dashboard.menu.homepage', 'fas fa-home', 'homepage'); |
||
| 254 | yield MenuItem::linkToUrl('dashboard.menu.stura', 'fab fa-rebel', 'https://www.stura.uni-jena.de/'); |
||
| 255 | yield MenuItem::linkToUrl('dashboard.menu.github', 'fab fa-github', 'https://github.com/jbtronics/StuRa-Finanzsoftware'); |
||
| 256 | } |
||
| 289 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.