| 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 |
||
| 119 | public function resultsFilter($query, $showDeleted = false) |
||
| 120 | { |
||
| 121 | |||
| 122 | $queryFilter = array(); |
||
| 123 | |||
| 124 | // Frontend only |
||
| 125 | $searchResultsFilter = $this->settings['searchResultsFilter']; |
||
| 126 | if(!empty($searchResultsFilter)) { |
||
| 127 | |||
| 128 | // add doctypes |
||
| 129 | if($searchResultsFilter['doctype']) { |
||
| 130 | |||
| 131 | $uids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $searchResultsFilter['doctype']); |
||
| 132 | $documentTypeRepository = $this->documentTypeRepository; |
||
| 133 | $documentTypes = array(); |
||
| 134 | foreach($uids as $uid) { |
||
| 135 | $documentType = $documentTypeRepository->findByUid($uid); |
||
| 136 | $documentTypes[] = $documentType->getName(); |
||
| 137 | }; |
||
| 138 | $searchResultsFilter['doctype'] = implode(',', $documentTypes); |
||
| 139 | } |
||
| 140 | |||
| 141 | // add date filter |
||
| 142 | $dateFilter = array(); |
||
| 143 | if ($searchResultsFilter['from']) { |
||
| 144 | |||
| 145 | $from = date('d.m.Y', $searchResultsFilter['from']); |
||
| 146 | $dateTime = $this->convertFormDate($from, false); |
||
| 147 | $dateFilter['gte'] = $dateTime->format('Y-m-d'); |
||
| 148 | unset($searchResultsFilter['from']); |
||
| 149 | |||
| 150 | } |
||
| 151 | |||
| 152 | if ($searchResultsFilter['till']) { |
||
| 153 | |||
| 154 | $till = date('d.m.Y', $searchResultsFilter['till']); |
||
| 155 | $dateTime = $this->convertFormDate($till, true); |
||
| 156 | $dateFilter['lte'] = $dateTime->format('Y-m-d'); |
||
| 157 | unset($searchResultsFilter['till']); |
||
| 158 | |||
| 159 | } |
||
| 160 | |||
| 161 | if (isset($dateFilter['gte']) || isset($dateFilter['lte'])) { |
||
| 162 | |||
| 163 | $queryFilter['body']['query']['bool']['must'][] = array('range' => array('distribution_date' => $dateFilter)); |
||
| 164 | |||
| 165 | } |
||
| 166 | |||
| 167 | foreach ($searchResultsFilter as $key => $qry) { |
||
| 168 | |||
| 169 | if(!empty($qry)) { |
||
| 170 | $queryFilter['body']['query']['bool']['must'][] = array('match' => array($key => $qry)); |
||
| 171 | } |
||
| 172 | |||
| 173 | } |
||
| 174 | |||
| 175 | } |
||
| 176 | |||
| 177 | // document must be active |
||
| 178 | if($showDeleted == false) { |
||
| 179 | |||
| 180 | $queryFilter['body']['query']['bool']['must'][]['term']['STATE'] = 'A'; |
||
| 181 | |||
| 182 | }; |
||
| 183 | |||
| 184 | // add OWNER_ID if present |
||
| 185 | $clients = $this->clientRepository->findAll(); |
||
| 186 | if ($clients) { |
||
| 187 | $client = $clients->getFirst(); |
||
| 188 | if ($client) { |
||
| 189 | $queryFilter['body']['query']['bool']['must'][]['term']['OWNER_ID'] = $client->getOwnerId(); |
||
| 190 | } |
||
| 191 | } |
||
| 192 | |||
| 193 | $queryFilter = array_merge_recursive($queryFilter, $query); |
||
| 194 | return $queryFilter; |
||
| 195 | } |
||
| 257 |
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