We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 20 |
| Paths | 28 |
| Total Lines | 173 |
| Code Lines | 120 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 46 | public function mainAction() |
||
| 47 | { |
||
| 48 | $requestData = $this->request->getArguments(); |
||
| 49 | |||
| 50 | // Create XML document. |
||
| 51 | $rss = new \DOMDocument('1.0', 'utf-8'); |
||
| 52 | // Add mandatory root element. |
||
| 53 | $root = $rss->createElement('rss'); |
||
| 54 | $root->setAttribute('version', '2.0'); |
||
| 55 | // Add channel element. |
||
| 56 | $channel = $rss->createElement('channel'); |
||
| 57 | $channel->appendChild($rss->createElement('title', htmlspecialchars($this->settings['title'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 58 | |||
| 59 | $currentUri = $this->controllerContext |
||
| 60 | ->getUriBuilder() |
||
| 61 | ->reset() |
||
| 62 | ->setTargetPageUid($GLOBALS["TSFE"]->id) |
||
| 63 | ->setAddQueryString(TRUE) |
||
| 64 | ->buildFrontendUri(); |
||
| 65 | $channel->appendChild($rss->createElement('link', htmlspecialchars(GeneralUtility::locationHeaderUrl($currentUri), ENT_NOQUOTES, 'UTF-8'))); |
||
| 66 | |||
| 67 | if (!empty($this->settings['description'])) { |
||
| 68 | $channel->appendChild($rss->createElement('description', htmlspecialchars($this->settings['description'], ENT_QUOTES, 'UTF-8'))); |
||
| 69 | } |
||
| 70 | |||
| 71 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 72 | ->getQueryBuilderForTable('tx_dlf_structures'); |
||
| 73 | |||
| 74 | $result = $queryBuilder |
||
| 75 | ->select('tx_dlf_libraries.label AS label') |
||
| 76 | ->from('tx_dlf_libraries') |
||
| 77 | ->where( |
||
| 78 | $queryBuilder->expr()->eq('tx_dlf_libraries.pid', (int)$this->settings['pages']), |
||
| 79 | $queryBuilder->expr()->eq('tx_dlf_libraries.uid', (int)$this->settings['library']), |
||
| 80 | Helper::whereExpression('tx_dlf_libraries') |
||
| 81 | ) |
||
| 82 | ->setMaxResults(1) |
||
| 83 | ->execute(); |
||
| 84 | |||
| 85 | $allResults = $result->fetchAll(); |
||
| 86 | |||
| 87 | if (count($allResults) === 1) { |
||
| 88 | $resArray = $allResults[0]; |
||
| 89 | $channel->appendChild($rss->createElement('copyright', htmlspecialchars($resArray['label'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 90 | } |
||
| 91 | $channel->appendChild($rss->createElement('pubDate', date('r', $GLOBALS['EXEC_TIME']))); |
||
| 92 | $channel->appendChild($rss->createElement('generator', htmlspecialchars($this->settings['useragent'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 93 | // Add item elements. |
||
| 94 | if ( |
||
| 95 | !$this->settings['excludeOther'] |
||
| 96 | || empty($requestData['collection']) |
||
| 97 | || GeneralUtility::inList($this->settings['collections'], $requestData['collection']) |
||
| 98 | ) { |
||
| 99 | $additionalWhere = ''; |
||
| 100 | // Check for pre-selected collections. |
||
| 101 | if (!empty($requestData['collection'])) { |
||
| 102 | $additionalWhere = 'tx_dlf_collections.uid=' . (int)$requestData['collection']; |
||
| 103 | } elseif (!empty($this->settings['collections'])) { |
||
| 104 | $additionalWhere = 'tx_dlf_collections.uid IN (' . implode(',', GeneralUtility::intExplode(',', $this->settings['collections'])) . ')'; |
||
| 105 | } |
||
| 106 | |||
| 107 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 108 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 109 | |||
| 110 | $result = $queryBuilder |
||
| 111 | ->select( |
||
| 112 | 'tx_dlf_documents.uid AS uid', |
||
| 113 | 'tx_dlf_documents.partof AS partof', |
||
| 114 | 'tx_dlf_documents.title AS title', |
||
| 115 | 'tx_dlf_documents.volume AS volume', |
||
| 116 | 'tx_dlf_documents.author AS author', |
||
| 117 | 'tx_dlf_documents.record_id AS guid', |
||
| 118 | 'tx_dlf_documents.tstamp AS tstamp', |
||
| 119 | 'tx_dlf_documents.crdate AS crdate' |
||
| 120 | ) |
||
| 121 | ->from('tx_dlf_documents') |
||
| 122 | ->join( |
||
| 123 | 'tx_dlf_documents', |
||
| 124 | 'tx_dlf_relations', |
||
| 125 | 'tx_dlf_documents_collections_mm', |
||
| 126 | $queryBuilder->expr()->eq('tx_dlf_documents.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_local')) |
||
| 127 | ) |
||
| 128 | ->join( |
||
| 129 | 'tx_dlf_documents_collections_mm', |
||
| 130 | 'tx_dlf_collections', |
||
| 131 | 'tx_dlf_collections', |
||
| 132 | $queryBuilder->expr()->eq('tx_dlf_collections.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_foreign')) |
||
| 133 | ) |
||
| 134 | ->where( |
||
| 135 | $queryBuilder->expr()->eq('tx_dlf_documents.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])), |
||
| 136 | $queryBuilder->expr()->eq('tx_dlf_documents_collections_mm.ident', $queryBuilder->createNamedParameter('docs_colls')), |
||
| 137 | $queryBuilder->expr()->eq('tx_dlf_collections.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])), |
||
| 138 | $additionalWhere, |
||
| 139 | Helper::whereExpression('tx_dlf_documents'), |
||
| 140 | Helper::whereExpression('tx_dlf_collections') |
||
| 141 | ) |
||
| 142 | ->groupBy('tx_dlf_documents.uid') |
||
| 143 | ->orderBy('tx_dlf_documents.tstamp', 'DESC') |
||
| 144 | ->setMaxResults((int) $this->settings['limit']) |
||
| 145 | ->execute(); |
||
| 146 | $rows = $result->fetchAll(); |
||
| 147 | |||
| 148 | if (count($rows) > 0) { |
||
| 149 | // Add each record as item element. |
||
| 150 | foreach ($rows as $resArray) { |
||
| 151 | $item = $rss->createElement('item'); |
||
| 152 | $title = ''; |
||
| 153 | // Get title of superior document. |
||
| 154 | if ((empty($resArray['title']) || !empty($this->settings['prependSuperiorTitle'])) |
||
| 155 | && !empty($resArray['partof']) |
||
| 156 | ) { |
||
| 157 | $superiorTitle = Document::getTitle($resArray['partof'], true); |
||
| 158 | if (!empty($superiorTitle)) { |
||
| 159 | $title .= '[' . $superiorTitle . ']'; |
||
| 160 | } |
||
| 161 | } |
||
| 162 | // Get title of document. |
||
| 163 | if (!empty($resArray['title'])) { |
||
| 164 | $title .= ' ' . $resArray['title']; |
||
| 165 | } |
||
| 166 | // Set default title if empty. |
||
| 167 | if (empty($title)) { |
||
| 168 | $title = $this->pi_getLL('noTitle'); |
||
| 169 | } |
||
| 170 | // Append volume information. |
||
| 171 | if (!empty($resArray['volume'])) { |
||
| 172 | $title .= ', ' . $this->pi_getLL('volume') . ' ' . $resArray['volume']; |
||
| 173 | } |
||
| 174 | // Is this document new or updated? |
||
| 175 | if ($resArray['crdate'] == $resArray['tstamp']) { |
||
| 176 | $title = $this->pi_getLL('new') . ' ' . trim($title); |
||
| 177 | } else { |
||
| 178 | $title = $this->pi_getLL('update') . ' ' . trim($title); |
||
| 179 | } |
||
| 180 | $item->appendChild($rss->createElement('title', htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'))); |
||
| 181 | // Add link. |
||
| 182 | $linkConf = [ |
||
| 183 | 'parameter' => $this->settings['targetPid'], |
||
| 184 | 'forceAbsoluteUrl' => 1, |
||
| 185 | 'forceAbsoluteUrl.' => ['scheme' => !empty($this->settings['forceAbsoluteUrlHttps']) ? 'https' : 'http'], |
||
| 186 | 'additionalParams' => GeneralUtility::implodeArrayForUrl($this->prefixId, ['id' => $resArray['uid']], '', true, false) |
||
| 187 | ]; |
||
| 188 | /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */ |
||
| 189 | $cObj = $this->configurationManager->getContentObject(); |
||
| 190 | |||
| 191 | $item->appendChild($rss->createElement('link', htmlspecialchars($cObj->typoLink_URL($linkConf), ENT_NOQUOTES, 'UTF-8'))); |
||
| 192 | // Add author if applicable. |
||
| 193 | if (!empty($resArray['author'])) { |
||
| 194 | $item->appendChild($rss->createElement('author', htmlspecialchars($resArray['author'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 195 | } |
||
| 196 | // Add online publication date. |
||
| 197 | $item->appendChild($rss->createElement('pubDate', date('r', $resArray['crdate']))); |
||
| 198 | // Add internal record identifier. |
||
| 199 | $item->appendChild($rss->createElement('guid', htmlspecialchars($resArray['guid'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 200 | $channel->appendChild($item); |
||
| 201 | } |
||
| 202 | } |
||
| 203 | } |
||
| 204 | $root->appendChild($channel); |
||
| 205 | // Build XML output. |
||
| 206 | $rss->appendChild($root); |
||
| 207 | $content = $rss->saveXML(); |
||
| 208 | // Clean output buffer. |
||
| 209 | ob_end_clean(); |
||
| 210 | // Send headers. |
||
| 211 | header('HTTP/1.1 200 OK'); |
||
| 212 | header('Cache-Control: no-cache'); |
||
| 213 | header('Content-Length: ' . strlen($content)); |
||
| 214 | header('Content-Type: application/rss+xml; charset=utf-8'); |
||
| 215 | header('Date: ' . date('r', $GLOBALS['EXEC_TIME'])); |
||
| 216 | header('Expires: ' . date('r', $GLOBALS['EXEC_TIME'])); |
||
| 217 | echo $content; |
||
| 218 | exit; |
||
| 219 | } |
||
| 226 | } |
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