We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 16 |
| Paths | 541 |
| Total Lines | 98 |
| Code Lines | 59 |
| 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 |
||
| 83 | public function calendarAction() |
||
| 84 | { |
||
| 85 | $requestData = GeneralUtility::_GPmerged('tx_dlf'); |
||
| 86 | unset($requestData['__referrer'], $requestData['__trustedProperties']); |
||
| 87 | |||
| 88 | // access arguments passed by the mainAction() |
||
| 89 | $mainrequestData = $this->request->getArguments(); |
||
| 90 | |||
| 91 | // merge both arguments together --> passing id by GET parameter tx_dlf[id] should win |
||
| 92 | $requestData = array_merge($requestData, $mainrequestData); |
||
| 93 | |||
| 94 | // Load current document. |
||
| 95 | $this->loadDocument($requestData); |
||
| 96 | if ($this->doc === null) { |
||
| 97 | // Quit without doing anything if required variables are not set. |
||
| 98 | return; |
||
| 99 | } |
||
| 100 | |||
| 101 | $documents = $this->documentRepository->getChildrenOfYearAnchor($this->doc->uid, 'issue'); |
||
| 102 | |||
| 103 | $issues = []; |
||
| 104 | |||
| 105 | // Process results. |
||
| 106 | /** @var Document $document */ |
||
| 107 | foreach ($documents as $document) { |
||
| 108 | // Set title for display in calendar view. |
||
| 109 | if (!empty($document->getTitle())) { |
||
| 110 | $title = $document->getTitle(); |
||
| 111 | } else { |
||
| 112 | $title = !empty($document->getMetsLabel()) ? $document->getMetsLabel() : $document->getMetsOrderlabel(); |
||
| 113 | if (strtotime($title) !== false) { |
||
| 114 | $title = strftime('%x', strtotime($title)); |
||
| 115 | } |
||
| 116 | } |
||
| 117 | $issues[] = [ |
||
| 118 | 'uid' => $document->getUid(), |
||
| 119 | 'title' => $title, |
||
| 120 | 'year' => $document->getYear() |
||
| 121 | ]; |
||
| 122 | } |
||
| 123 | |||
| 124 | // We need an array of issues with year => month => day number as key. |
||
| 125 | $calendarIssuesByYear = []; |
||
| 126 | foreach ($issues as $issue) { |
||
| 127 | $dateTimestamp = strtotime($issue['year']); |
||
| 128 | if ($dateTimestamp !== false) { |
||
| 129 | $_year = date('Y', $dateTimestamp); |
||
| 130 | $_month = date('n', $dateTimestamp); |
||
| 131 | $_day = date('j', $dateTimestamp); |
||
| 132 | $calendarIssuesByYear[$_year][$_month][$_day][] = $issue; |
||
| 133 | } else { |
||
| 134 | $this->logger->warning('Document with UID ' . $issue['uid'] . 'has no valid date of publication'); |
||
|
1 ignored issue
–
show
|
|||
| 135 | } |
||
| 136 | } |
||
| 137 | // Sort by years. |
||
| 138 | ksort($calendarIssuesByYear); |
||
| 139 | // Build calendar for year (default) or season. |
||
| 140 | $iteration = 1; |
||
| 141 | foreach ($calendarIssuesByYear as $year => $calendarIssuesByMonth) { |
||
| 142 | // Sort by months. |
||
| 143 | ksort($calendarIssuesByMonth); |
||
| 144 | // Default: First month is January, last month is December. |
||
| 145 | $firstMonth = 1; |
||
| 146 | $lastMonth = 12; |
||
| 147 | // Show calendar from first issue up to end of season if applicable. |
||
| 148 | if ( |
||
| 149 | empty($this->settings['showEmptyMonths']) |
||
| 150 | && count($calendarIssuesByYear) > 1 |
||
| 151 | ) { |
||
| 152 | if ($iteration == 1) { |
||
| 153 | $firstMonth = (int) key($calendarIssuesByMonth); |
||
| 154 | } elseif ($iteration == count($calendarIssuesByYear)) { |
||
| 155 | end($calendarIssuesByMonth); |
||
| 156 | $lastMonth = (int) key($calendarIssuesByMonth); |
||
| 157 | } |
||
| 158 | } |
||
| 159 | $this->getCalendarYear($calendarIssuesByMonth, $year, $firstMonth, $lastMonth); |
||
| 160 | $iteration++; |
||
| 161 | } |
||
| 162 | // Prepare list as alternative view. |
||
| 163 | $issueData = []; |
||
| 164 | foreach ($this->allIssues as $dayTimestamp => $issues) { |
||
| 165 | $issueData[$dayTimestamp]['dateString'] = strftime('%A, %x', $dayTimestamp); |
||
| 166 | $issueData[$dayTimestamp]['items'] = []; |
||
| 167 | foreach ($issues as $issue) { |
||
| 168 | $issueData[$dayTimestamp]['items'][] = $issue; |
||
| 169 | } |
||
| 170 | } |
||
| 171 | $this->view->assign('issueData', $issueData); |
||
| 172 | |||
| 173 | // Link to current year. |
||
| 174 | $linkTitleData = $this->doc->getTitledata(); |
||
| 175 | $yearLinkTitle = !empty($linkTitleData['mets_orderlabel'][0]) ? $linkTitleData['mets_orderlabel'][0] : $linkTitleData['mets_label'][0]; |
||
| 176 | |||
| 177 | $this->view->assign('documentId', $this->doc->uid); |
||
| 178 | $this->view->assign('yearLinkTitle', $yearLinkTitle); |
||
| 179 | $this->view->assign('parentDocumentId', $this->doc->parentId); |
||
| 180 | $this->view->assign('allYearDocTitle', $this->doc->getTitle($this->doc->parentId)); |
||
| 181 | } |
||
| 363 |
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.