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 | 113 |
| Code Lines | 83 |
| 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 |
||
| 281 | protected function getCalendarYear($calendarIssuesByMonth, $year, $firstMonth = 1, $lastMonth = 12) |
||
| 282 | { |
||
| 283 | $calendarData = []; |
||
| 284 | for ($i = $firstMonth; $i <= $lastMonth; $i++) { |
||
| 285 | $calendarData[$i] = [ |
||
| 286 | 'DAYMON_NAME' => strftime('%a', strtotime('last Monday')), |
||
| 287 | 'DAYTUE_NAME' => strftime('%a', strtotime('last Tuesday')), |
||
| 288 | 'DAYWED_NAME' => strftime('%a', strtotime('last Wednesday')), |
||
| 289 | 'DAYTHU_NAME' => strftime('%a', strtotime('last Thursday')), |
||
| 290 | 'DAYFRI_NAME' => strftime('%a', strtotime('last Friday')), |
||
| 291 | 'DAYSAT_NAME' => strftime('%a', strtotime('last Saturday')), |
||
| 292 | 'DAYSUN_NAME' => strftime('%a', strtotime('last Sunday')), |
||
| 293 | 'MONTHNAME' => strftime('%B', strtotime($year . '-' . $i . '-1')) . ' ' . $year, |
||
| 294 | 'CALYEAR' => ($i == $firstMonth) ? $year : '' |
||
| 295 | ]; |
||
| 296 | |||
| 297 | $firstOfMonth = strtotime($year . '-' . $i . '-1'); |
||
| 298 | $lastOfMonth = strtotime('last day of', ($firstOfMonth)); |
||
| 299 | $firstOfMonthStart = strtotime('last Monday', $firstOfMonth); |
||
| 300 | // There are never more than 6 weeks in a month. |
||
| 301 | for ($j = 0; $j <= 5; $j++) { |
||
| 302 | $firstDayOfWeek = strtotime('+ ' . $j . ' Week', $firstOfMonthStart); |
||
| 303 | |||
| 304 | $calendarData[$i]['week'][$j] = [ |
||
| 305 | 'DAYMON' => ['dayValue' => ' '], |
||
| 306 | 'DAYTUE' => ['dayValue' => ' '], |
||
| 307 | 'DAYWED' => ['dayValue' => ' '], |
||
| 308 | 'DAYTHU' => ['dayValue' => ' '], |
||
| 309 | 'DAYFRI' => ['dayValue' => ' '], |
||
| 310 | 'DAYSAT' => ['dayValue' => ' '], |
||
| 311 | 'DAYSUN' => ['dayValue' => ' '], |
||
| 312 | ]; |
||
| 313 | // Every week has seven days. ;-) |
||
| 314 | for ($k = 0; $k <= 6; $k++) { |
||
| 315 | $currentDayTime = strtotime('+ ' . $k . ' Day', $firstDayOfWeek); |
||
| 316 | if ( |
||
| 317 | $currentDayTime >= $firstOfMonth |
||
| 318 | && $currentDayTime <= $lastOfMonth |
||
| 319 | ) { |
||
| 320 | $dayLinks = ''; |
||
| 321 | $dayLinksText = []; |
||
| 322 | $currentMonth = date('n', $currentDayTime); |
||
| 323 | if (is_array($calendarIssuesByMonth[$currentMonth])) { |
||
| 324 | foreach ($calendarIssuesByMonth[$currentMonth] as $id => $day) { |
||
| 325 | if ($id == date('j', $currentDayTime)) { |
||
| 326 | $dayLinks = $id; |
||
| 327 | foreach ($day as $issue) { |
||
| 328 | $dayLinkLabel = empty($issue['title']) ? strftime('%x', $currentDayTime) : $issue['title']; |
||
| 329 | |||
| 330 | $dayLinksText[] = [ |
||
| 331 | 'documentId' => $issue['uid'], |
||
| 332 | 'text' => $dayLinkLabel |
||
| 333 | ]; |
||
| 334 | |||
| 335 | // Save issue for list view. |
||
| 336 | $this->allIssues[$currentDayTime][] = [ |
||
| 337 | 'documentId' => $issue['uid'], |
||
| 338 | 'text' => $dayLinkLabel |
||
| 339 | ]; |
||
| 340 | } |
||
| 341 | } |
||
| 342 | } |
||
| 343 | $dayLinkDiv = $dayLinksText; |
||
| 344 | } |
||
| 345 | switch (strftime('%w', strtotime('+ ' . $k . ' Day', $firstDayOfWeek))) { |
||
| 346 | case '0': |
||
| 347 | $calendarData[$i]['week'][$j]['DAYSUN']['dayValue'] = strftime('%d', $currentDayTime); |
||
| 348 | if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
||
| 349 | $calendarData[$i]['week'][$j]['DAYSUN']['issues'] = $dayLinkDiv; |
||
| 350 | } |
||
| 351 | break; |
||
| 352 | case '1': |
||
| 353 | $calendarData[$i]['week'][$j]['DAYMON']['dayValue'] = strftime('%d', $currentDayTime); |
||
| 354 | if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
||
| 355 | $calendarData[$i]['week'][$j]['DAYMON']['issues'] = $dayLinkDiv; |
||
| 356 | } |
||
| 357 | break; |
||
| 358 | case '2': |
||
| 359 | $calendarData[$i]['week'][$j]['DAYTUE']['dayValue'] = strftime('%d', $currentDayTime); |
||
| 360 | if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
||
| 361 | $calendarData[$i]['week'][$j]['DAYTUE']['issues'] = $dayLinkDiv; |
||
| 362 | } |
||
| 363 | break; |
||
| 364 | case '3': |
||
| 365 | $calendarData[$i]['week'][$j]['DAYWED']['dayValue'] = strftime('%d', $currentDayTime); |
||
| 366 | if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
||
| 367 | $calendarData[$i]['week'][$j]['DAYWED']['issues'] = $dayLinkDiv; |
||
| 368 | } |
||
| 369 | break; |
||
| 370 | case '4': |
||
| 371 | $calendarData[$i]['week'][$j]['DAYTHU']['dayValue'] = strftime('%d', $currentDayTime); |
||
| 372 | if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
||
| 373 | $calendarData[$i]['week'][$j]['DAYTHU']['issues'] = $dayLinkDiv; |
||
| 374 | } |
||
| 375 | break; |
||
| 376 | case '5': |
||
| 377 | $calendarData[$i]['week'][$j]['DAYFRI']['dayValue'] = strftime('%d', $currentDayTime); |
||
| 378 | if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
||
| 379 | $calendarData[$i]['week'][$j]['DAYFRI']['issues'] = $dayLinkDiv; |
||
| 380 | } |
||
| 381 | break; |
||
| 382 | case '6': |
||
| 383 | $calendarData[$i]['week'][$j]['DAYSAT']['dayValue'] = strftime('%d', $currentDayTime); |
||
| 384 | if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
||
| 385 | $calendarData[$i]['week'][$j]['DAYSAT']['issues'] = $dayLinkDiv; |
||
| 386 | } |
||
| 387 | break; |
||
| 388 | } |
||
| 389 | } |
||
| 390 | } |
||
| 391 | } |
||
| 392 | } |
||
| 393 | $this->view->assign('calendarData', $calendarData); |
||
| 394 | } |
||
| 396 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.