We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 26 | 
| Paths | 67 | 
| Total Lines | 114 | 
| Code Lines | 84 | 
| 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 | ||
| 262 | protected function getCalendarYear($calendarIssuesByMonth, $year, $firstMonth = 1, $lastMonth = 12) | ||
| 263 |     { | ||
| 264 | $calendarData = []; | ||
| 265 |         for ($i = $firstMonth; $i <= $lastMonth; $i++) { | ||
| 266 | $calendarData[$i] = [ | ||
| 267 |                 'DAYMON_NAME' => strftime('%a', strtotime('last Monday')), | ||
| 268 |                 'DAYTUE_NAME' => strftime('%a', strtotime('last Tuesday')), | ||
| 269 |                 'DAYWED_NAME' => strftime('%a', strtotime('last Wednesday')), | ||
| 270 |                 'DAYTHU_NAME' => strftime('%a', strtotime('last Thursday')), | ||
| 271 |                 'DAYFRI_NAME' => strftime('%a', strtotime('last Friday')), | ||
| 272 |                 'DAYSAT_NAME' => strftime('%a', strtotime('last Saturday')), | ||
| 273 |                 'DAYSUN_NAME' => strftime('%a', strtotime('last Sunday')), | ||
| 274 |                 'MONTHNAME'  => strftime('%B', strtotime($year . '-' . $i . '-1')) . ' ' . $year, | ||
| 275 | 'CALYEAR' => ($i == $firstMonth) ? $year : '' | ||
| 276 | ]; | ||
| 277 | |||
| 278 | $firstOfMonth = strtotime($year . '-' . $i . '-1'); | ||
| 279 |             $lastOfMonth = strtotime('last day of', ($firstOfMonth)); | ||
| 280 |             $firstOfMonthStart = strtotime('last Monday', $firstOfMonth); | ||
| 281 | // There are never more than 6 weeks in a month. | ||
| 282 |             for ($j = 0; $j <= 5; $j++) { | ||
| 283 |                 $firstDayOfWeek = strtotime('+ ' . $j . ' Week', $firstOfMonthStart); | ||
| 284 | |||
| 285 | $calendarData[$i]['week'][$j] = [ | ||
| 286 | 'DAYMON' => ['dayValue' => ' '], | ||
| 287 | 'DAYTUE' => ['dayValue' => ' '], | ||
| 288 | 'DAYWED' => ['dayValue' => ' '], | ||
| 289 | 'DAYTHU' => ['dayValue' => ' '], | ||
| 290 | 'DAYFRI' => ['dayValue' => ' '], | ||
| 291 | 'DAYSAT' => ['dayValue' => ' '], | ||
| 292 | 'DAYSUN' => ['dayValue' => ' '], | ||
| 293 | ]; | ||
| 294 | // Every week has seven days. ;-) | ||
| 295 |                 for ($k = 0; $k <= 6; $k++) { | ||
| 296 |                     $currentDayTime = strtotime('+ ' . $k . ' Day', $firstDayOfWeek); | ||
| 297 | if ( | ||
| 298 | $currentDayTime >= $firstOfMonth | ||
| 299 | && $currentDayTime <= $lastOfMonth | ||
| 300 |                     ) { | ||
| 301 | $dayLinks = ''; | ||
| 302 | $dayLinksText = []; | ||
| 303 | $dayLinkDiv = []; | ||
| 304 |                         $currentMonth = date('n', $currentDayTime); | ||
| 305 |                         if (is_array($calendarIssuesByMonth[$currentMonth])) { | ||
| 306 |                             foreach ($calendarIssuesByMonth[$currentMonth] as $id => $day) { | ||
| 307 |                                 if ($id == date('j', $currentDayTime)) { | ||
| 308 | $dayLinks = $id; | ||
| 309 |                                     foreach ($day as $issue) { | ||
| 310 |                                         $dayLinkLabel = empty($issue['title']) ? strftime('%x', $currentDayTime) : $issue['title']; | ||
| 311 | |||
| 312 | $dayLinksText[] = [ | ||
| 313 | 'documentId' => $issue['uid'], | ||
| 314 | 'text' => $dayLinkLabel | ||
| 315 | ]; | ||
| 316 | |||
| 317 | // Save issue for list view. | ||
| 318 | $this->allIssues[$currentDayTime][] = [ | ||
| 319 | 'documentId' => $issue['uid'], | ||
| 320 | 'text' => $dayLinkLabel | ||
| 321 | ]; | ||
| 322 | } | ||
| 323 | } | ||
| 324 | } | ||
| 325 | $dayLinkDiv = $dayLinksText; | ||
| 326 | } | ||
| 327 |                         switch (strftime('%w', strtotime('+ ' . $k . ' Day', $firstDayOfWeek))) { | ||
| 328 | case '0': | ||
| 329 |                                 $calendarData[$i]['week'][$j]['DAYSUN']['dayValue'] = strftime('%d', $currentDayTime); | ||
| 330 |                                 if ((int) $dayLinks === (int) date('j', $currentDayTime)) { | ||
| 331 | $calendarData[$i]['week'][$j]['DAYSUN']['issues'] = $dayLinkDiv; | ||
| 332 | } | ||
| 333 | break; | ||
| 334 | case '1': | ||
| 335 |                                 $calendarData[$i]['week'][$j]['DAYMON']['dayValue'] = strftime('%d', $currentDayTime); | ||
| 336 |                                 if ((int) $dayLinks === (int) date('j', $currentDayTime)) { | ||
| 337 | $calendarData[$i]['week'][$j]['DAYMON']['issues'] = $dayLinkDiv; | ||
| 338 | } | ||
| 339 | break; | ||
| 340 | case '2': | ||
| 341 |                                 $calendarData[$i]['week'][$j]['DAYTUE']['dayValue'] = strftime('%d', $currentDayTime); | ||
| 342 |                                 if ((int) $dayLinks === (int) date('j', $currentDayTime)) { | ||
| 343 | $calendarData[$i]['week'][$j]['DAYTUE']['issues'] = $dayLinkDiv; | ||
| 344 | } | ||
| 345 | break; | ||
| 346 | case '3': | ||
| 347 |                                 $calendarData[$i]['week'][$j]['DAYWED']['dayValue'] = strftime('%d', $currentDayTime); | ||
| 348 |                                 if ((int) $dayLinks === (int) date('j', $currentDayTime)) { | ||
| 349 | $calendarData[$i]['week'][$j]['DAYWED']['issues'] = $dayLinkDiv; | ||
| 350 | } | ||
| 351 | break; | ||
| 352 | case '4': | ||
| 353 |                                 $calendarData[$i]['week'][$j]['DAYTHU']['dayValue'] = strftime('%d', $currentDayTime); | ||
| 354 |                                 if ((int) $dayLinks === (int) date('j', $currentDayTime)) { | ||
| 355 | $calendarData[$i]['week'][$j]['DAYTHU']['issues'] = $dayLinkDiv; | ||
| 356 | } | ||
| 357 | break; | ||
| 358 | case '5': | ||
| 359 |                                 $calendarData[$i]['week'][$j]['DAYFRI']['dayValue'] = strftime('%d', $currentDayTime); | ||
| 360 |                                 if ((int) $dayLinks === (int) date('j', $currentDayTime)) { | ||
| 361 | $calendarData[$i]['week'][$j]['DAYFRI']['issues'] = $dayLinkDiv; | ||
| 362 | } | ||
| 363 | break; | ||
| 364 | case '6': | ||
| 365 |                                 $calendarData[$i]['week'][$j]['DAYSAT']['dayValue'] = strftime('%d', $currentDayTime); | ||
| 366 |                                 if ((int) $dayLinks === (int) date('j', $currentDayTime)) { | ||
| 367 | $calendarData[$i]['week'][$j]['DAYSAT']['issues'] = $dayLinkDiv; | ||
| 368 | } | ||
| 369 | break; | ||
| 370 | } | ||
| 371 | } | ||
| 372 | } | ||
| 373 | } | ||
| 374 | } | ||
| 375 |         $this->view->assign('calendarData', $calendarData); | ||
| 376 | } | ||
| 378 |