| Conditions | 13 |
| Paths | 102 |
| Total Lines | 76 |
| Code Lines | 36 |
| 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 |
||
| 135 | public function resultsFilter($query, $showDeleted = false) |
||
| 136 | { |
||
| 137 | |||
| 138 | $queryFilter = array(); |
||
| 139 | |||
| 140 | // Frontend only |
||
| 141 | $searchResultsFilter = $this->settings['searchResultsFilter']; |
||
| 142 | if(!empty($searchResultsFilter)) { |
||
| 143 | |||
| 144 | // add doctypes |
||
| 145 | if($searchResultsFilter['doctype']) { |
||
| 146 | |||
| 147 | $uids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $searchResultsFilter['doctype']); |
||
| 148 | $documentTypeRepository = $this->documentTypeRepository; |
||
| 149 | $documentTypes = array(); |
||
| 150 | foreach($uids as $uid) { |
||
| 151 | $documentType = $documentTypeRepository->findByUid($uid); |
||
| 152 | $documentTypes[] = $documentType->getName(); |
||
| 153 | }; |
||
| 154 | $searchResultsFilter['doctype'] = implode(',', $documentTypes); |
||
| 155 | } |
||
| 156 | |||
| 157 | // add date filter |
||
| 158 | $dateFilter = array(); |
||
| 159 | if ($searchResultsFilter['from']) { |
||
| 160 | |||
| 161 | $from = date('d.m.Y', $searchResultsFilter['from']); |
||
| 162 | $dateTime = $this->convertFormDate($from, false); |
||
| 163 | $dateFilter['gte'] = $dateTime->format('Y-m-d'); |
||
| 164 | unset($searchResultsFilter['from']); |
||
| 165 | |||
| 166 | } |
||
| 167 | |||
| 168 | if ($searchResultsFilter['till']) { |
||
| 169 | |||
| 170 | $till = date('d.m.Y', $searchResultsFilter['till']); |
||
| 171 | $dateTime = $this->convertFormDate($till, true); |
||
| 172 | $dateFilter['lte'] = $dateTime->format('Y-m-d'); |
||
| 173 | unset($searchResultsFilter['till']); |
||
| 174 | |||
| 175 | } |
||
| 176 | |||
| 177 | if (isset($dateFilter['gte']) || isset($dateFilter['lte'])) { |
||
| 178 | |||
| 179 | $queryFilter['body']['query']['bool']['must'][] = array('range' => array('distribution_date' => $dateFilter)); |
||
| 180 | |||
| 181 | } |
||
| 182 | |||
| 183 | foreach ($searchResultsFilter as $key => $qry) { |
||
| 184 | |||
| 185 | if(!empty($qry)) { |
||
| 186 | $queryFilter['body']['query']['bool']['must'][] = array('match' => array($key => $qry)); |
||
| 187 | } |
||
| 188 | |||
| 189 | } |
||
| 190 | |||
| 191 | } |
||
| 192 | |||
| 193 | // document must be active |
||
| 194 | if($showDeleted == false) { |
||
| 195 | |||
| 196 | $queryFilter['body']['query']['bool']['must'][]['term']['STATE'] = 'A'; |
||
| 197 | |||
| 198 | }; |
||
| 199 | |||
| 200 | // add OWNER_ID if present |
||
| 201 | $clients = $this->clientRepository->findAll(); |
||
| 202 | if ($clients) { |
||
| 203 | $client = $clients->getFirst(); |
||
| 204 | if ($client) { |
||
| 205 | $queryFilter['body']['query']['bool']['must'][]['term']['OWNER_ID'] = $client->getOwnerId(); |
||
| 206 | } |
||
| 207 | } |
||
| 208 | |||
| 209 | $queryFilter = array_merge_recursive($queryFilter, $query); |
||
| 210 | return $queryFilter; |
||
| 211 | } |
||
| 273 |
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