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