| Conditions | 12 |
| Paths | 512 |
| Total Lines | 85 |
| Code Lines | 59 |
| 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 |
||
| 40 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
| 41 | { |
||
| 42 | $tree = Validator::attributes($request)->tree(); |
||
| 43 | $view = Validator::attributes($request)->isInArray(['day', 'month', 'year'])->string('view'); |
||
| 44 | $cal = Validator::queryParams($request)->string('cal', ''); |
||
| 45 | $day = Validator::queryParams($request)->string('day', ''); |
||
| 46 | $month = Validator::queryParams($request)->string('month', ''); |
||
| 47 | $year = Validator::queryParams($request)->string('year', ''); |
||
| 48 | $filterev = Validator::queryParams($request)->string('filterev', 'BIRT-MARR-DEAT'); |
||
| 49 | $filterof = Validator::queryParams($request)->string('filterof', 'all'); |
||
| 50 | $filtersx = Validator::queryParams($request)->string('filtersx', ''); |
||
| 51 | |||
| 52 | if ($cal . $day . $month . $year === '') { |
||
| 53 | // No date specified? Use the most likely calendar |
||
| 54 | $cal = I18N::language()->calendar()->gedcomCalendarEscape(); |
||
| 55 | } |
||
| 56 | |||
| 57 | // need BC to parse date |
||
| 58 | if (str_starts_with($year, '-')) { |
||
| 59 | $year = substr($year, 1) . ' B.C.'; |
||
| 60 | } |
||
| 61 | $ged_date = new Date($cal . ' ' . $day . ' ' . $month . ' ' . $year); |
||
| 62 | // need negative year for year entry field. |
||
| 63 | $year = $ged_date->minimumDate()->year; |
||
| 64 | $cal_date = $ged_date->minimumDate(); |
||
| 65 | |||
| 66 | // Fill in any missing bits with todays date |
||
| 67 | $today = $cal_date->today(); |
||
| 68 | if ($cal_date->day === 0) { |
||
| 69 | $cal_date->day = $today->day; |
||
| 70 | } |
||
| 71 | if ($cal_date->month === 0) { |
||
| 72 | $cal_date->month = $today->month; |
||
| 73 | } |
||
| 74 | if ($cal_date->year === 0) { |
||
| 75 | $cal_date->year = $today->year; |
||
| 76 | } |
||
| 77 | |||
| 78 | $cal_date->setJdFromYmd(); |
||
| 79 | |||
| 80 | if ($year === 0) { |
||
| 81 | $year = $cal_date->year; |
||
| 82 | } |
||
| 83 | |||
| 84 | // Extract values from date |
||
| 85 | $days_in_month = $cal_date->daysInMonth(); |
||
| 86 | $cal_month = $cal_date->format('%O'); |
||
| 87 | $today_month = $today->format('%O'); |
||
| 88 | |||
| 89 | // Invalid dates? Go to monthly view, where they'll be found. |
||
| 90 | if ($cal_date->day > $days_in_month && $view === 'day') { |
||
| 91 | $view = 'month'; |
||
| 92 | } |
||
| 93 | |||
| 94 | $title = I18N::translate('Anniversary calendar'); |
||
| 95 | |||
| 96 | switch ($view) { |
||
| 97 | case 'day': |
||
| 98 | $title = I18N::translate('On this day…') . ' ' . $ged_date->display($tree); |
||
| 99 | break; |
||
| 100 | case 'month': |
||
| 101 | $title = I18N::translate('In this month…') . ' ' . $ged_date->display($tree, '%F %Y'); |
||
| 102 | break; |
||
| 103 | case 'year': |
||
| 104 | $title = I18N::translate('In this year…') . ' ' . $ged_date->display($tree, '%Y'); |
||
| 105 | break; |
||
| 106 | } |
||
| 107 | |||
| 108 | return $this->viewResponse('calendar-page', [ |
||
| 109 | 'cal' => $cal, |
||
| 110 | 'cal_date' => $cal_date, |
||
| 111 | 'cal_month' => $cal_month, |
||
| 112 | 'day' => $day, |
||
| 113 | 'days_in_month' => $days_in_month, |
||
| 114 | 'filterev' => $filterev, |
||
| 115 | 'filterof' => $filterof, |
||
| 116 | 'filtersx' => $filtersx, |
||
| 117 | 'month' => $month, |
||
| 118 | 'months' => $this->calendar_service->calendarMonthsInYear($cal, $year), |
||
| 119 | 'title' => $title, |
||
| 120 | 'today' => $today, |
||
| 121 | 'today_month' => $today_month, |
||
| 122 | 'tree' => $tree, |
||
| 123 | 'view' => $view, |
||
| 124 | 'year' => $year, |
||
| 125 | ]); |
||
| 128 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths