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 | 115 |
| Code Lines | 74 |
| 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 |
||
| 84 | public function calendarAction() |
||
| 85 | { |
||
| 86 | $requestData = GeneralUtility::_GPmerged('tx_dlf'); |
||
| 87 | unset($requestData['__referrer'], $requestData['__trustedProperties']); |
||
| 88 | |||
| 89 | // access arguments passed by the mainAction() |
||
| 90 | $mainrquestData = $this->request->getArguments(); |
||
| 91 | |||
| 92 | // merge both arguments together --> passing id by GET parameter tx_dlf[id] should win |
||
| 93 | $requestData = array_merge($requestData, $mainrquestData); |
||
| 94 | |||
| 95 | // Load current document. |
||
| 96 | $this->loadDocument($requestData); |
||
| 97 | if ($this->doc === null) { |
||
| 98 | // Quit without doing anything if required variables are not set. |
||
| 99 | return; |
||
| 100 | } |
||
| 101 | |||
| 102 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 103 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 104 | |||
| 105 | // Get all children of year anchor. |
||
| 106 | $result = $queryBuilder |
||
| 107 | ->select( |
||
| 108 | 'tx_dlf_documents.uid AS uid', |
||
| 109 | 'tx_dlf_documents.title AS title', |
||
| 110 | 'tx_dlf_documents.year AS year', |
||
| 111 | 'tx_dlf_documents.mets_label AS label', |
||
| 112 | 'tx_dlf_documents.mets_orderlabel AS orderlabel' |
||
| 113 | ) |
||
| 114 | ->from('tx_dlf_documents') |
||
| 115 | ->where( |
||
| 116 | $queryBuilder->expr()->eq('tx_dlf_documents.structure', Helper::getUidFromIndexName('issue', 'tx_dlf_structures', $this->doc->cPid)), |
||
| 117 | $queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($this->doc->uid)), |
||
| 118 | Helper::whereExpression('tx_dlf_documents') |
||
| 119 | ) |
||
| 120 | ->orderBy('tx_dlf_documents.mets_orderlabel') |
||
| 121 | ->execute(); |
||
| 122 | |||
| 123 | $issues = []; |
||
| 124 | |||
| 125 | // Process results. |
||
| 126 | while ($resArray = $result->fetch()) { |
||
| 127 | // Set title for display in calendar view. |
||
| 128 | if (!empty($resArray['title'])) { |
||
| 129 | $title = $resArray['title']; |
||
| 130 | } else { |
||
| 131 | $title = !empty($resArray['label']) ? $resArray['label'] : $resArray['orderlabel']; |
||
| 132 | if (strtotime($title) !== false) { |
||
| 133 | $title = strftime('%x', strtotime($title)); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | $issues[] = [ |
||
| 137 | 'uid' => $resArray['uid'], |
||
| 138 | 'title' => $title, |
||
| 139 | 'year' => $resArray['year'] |
||
| 140 | ]; |
||
| 141 | } |
||
| 142 | // We need an array of issues with year => month => day number as key. |
||
| 143 | $calendarIssuesByYear = []; |
||
| 144 | foreach ($issues as $issue) { |
||
| 145 | $dateTimestamp = strtotime($issue['year']); |
||
| 146 | if ($dateTimestamp !== false) { |
||
| 147 | $_year = date('Y', $dateTimestamp); |
||
| 148 | $_month = date('n', $dateTimestamp); |
||
| 149 | $_day = date('j', $dateTimestamp); |
||
| 150 | $calendarIssuesByYear[$_year][$_month][$_day][] = $issue; |
||
| 151 | } else { |
||
| 152 | $this->logger->warning('Document with UID ' . $issue['uid'] . 'has no valid date of publication'); |
||
|
1 ignored issue
–
show
|
|||
| 153 | } |
||
| 154 | } |
||
| 155 | // Sort by years. |
||
| 156 | ksort($calendarIssuesByYear); |
||
| 157 | // Build calendar for year (default) or season. |
||
| 158 | $iteration = 1; |
||
| 159 | foreach ($calendarIssuesByYear as $year => $calendarIssuesByMonth) { |
||
| 160 | // Sort by months. |
||
| 161 | ksort($calendarIssuesByMonth); |
||
| 162 | // Default: First month is January, last month is December. |
||
| 163 | $firstMonth = 1; |
||
| 164 | $lastMonth = 12; |
||
| 165 | // Show calendar from first issue up to end of season if applicable. |
||
| 166 | if ( |
||
| 167 | empty($this->settings['showEmptyMonths']) |
||
| 168 | && count($calendarIssuesByYear) > 1 |
||
| 169 | ) { |
||
| 170 | if ($iteration == 1) { |
||
| 171 | $firstMonth = (int) key($calendarIssuesByMonth); |
||
| 172 | } elseif ($iteration == count($calendarIssuesByYear)) { |
||
| 173 | end($calendarIssuesByMonth); |
||
| 174 | $lastMonth = (int) key($calendarIssuesByMonth); |
||
| 175 | } |
||
| 176 | } |
||
| 177 | $this->getCalendarYear($calendarIssuesByMonth, $year, $firstMonth, $lastMonth); |
||
| 178 | $iteration++; |
||
| 179 | } |
||
| 180 | // Prepare list as alternative view. |
||
| 181 | $issueData = []; |
||
| 182 | foreach ($this->allIssues as $dayTimestamp => $issues) { |
||
| 183 | $issueData[$dayTimestamp]['dateString'] = strftime('%A, %x', $dayTimestamp); |
||
| 184 | $issueData[$dayTimestamp]['items'] = []; |
||
| 185 | foreach ($issues as $issue) { |
||
| 186 | $issueData[$dayTimestamp]['items'][] = $issue; |
||
| 187 | } |
||
| 188 | } |
||
| 189 | $this->view->assign('issueData', $issueData); |
||
| 190 | |||
| 191 | // Link to current year. |
||
| 192 | $linkTitleData = $this->doc->getTitledata(); |
||
| 193 | $yearLinkTitle = !empty($linkTitleData['mets_orderlabel'][0]) ? $linkTitleData['mets_orderlabel'][0] : $linkTitleData['mets_label'][0]; |
||
| 194 | |||
| 195 | $this->view->assign('documentId', $this->doc->uid); |
||
| 196 | $this->view->assign('yearLinkTitle', $yearLinkTitle); |
||
| 197 | $this->view->assign('parentDocumentId', $this->doc->parentId); |
||
| 198 | $this->view->assign('allYearDocTitle', $this->doc->getTitle($this->doc->parentId)); |
||
| 199 | } |
||
| 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.