Conditions | 4 |
Paths | 8 |
Total Lines | 67 |
Code Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
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 declare(strict_types = 1); |
||
31 | public function search(?string $q): SearchResults |
||
32 | { |
||
33 | $q = \is_null($q) |
||
34 | ? '' |
||
35 | : $q; |
||
36 | if ($this->searchType === SearchParamTypes::OR) { |
||
37 | $q = $this->makeQueryOr($q); |
||
38 | } |
||
39 | $startTime = \microtime(true); |
||
40 | $client = new Client(); |
||
41 | $manticoreClient = $client->getConnection(); |
||
42 | |||
43 | $searcher = new Search($manticoreClient); |
||
44 | $searcher->setIndex($this->indexName); |
||
45 | |||
46 | $searcher->limit($this->pageSize); |
||
47 | $offset=$this->pageSize * ($this->page-1); |
||
48 | $searcher->offset($offset); |
||
49 | |||
50 | $indexes = new Indexes(); |
||
51 | $index = $indexes->getIndex($this->indexName); |
||
52 | |||
53 | $searcher->highlight( |
||
54 | [], |
||
55 | ['pre_tags' => '<b>', 'post_tags'=>'</b>'] |
||
56 | ); |
||
57 | |||
58 | // $q = 'sheep'; |
||
59 | \error_log('Q: ' . $q); |
||
60 | |||
61 | $manticoreResult = $searcher->search($q)->get(); |
||
62 | $allFields = $this->getAllFields($index); |
||
63 | |||
64 | |||
65 | $ssResult = new ArrayList(); |
||
66 | while ($manticoreResult->valid()) { |
||
67 | $hit = $manticoreResult->current(); |
||
68 | $source = $hit->getData(); |
||
69 | $ssDataObject = new DataObject(); |
||
70 | |||
71 | $this->populateSearchResult($ssDataObject, $allFields, $source); |
||
72 | |||
73 | // manticore lowercases fields, so as above normalize them back to the SS fieldnames |
||
74 | $highlights = $hit->getHighlight(); |
||
75 | $fieldsToHighlight = $index->getHighlightedFields(); |
||
76 | $this->addHighlights($ssDataObject, $allFields, $highlights, $fieldsToHighlight); |
||
77 | |||
78 | $ssDataObject->ID = $hit->getId(); |
||
79 | $ssResult->push($ssDataObject); |
||
80 | $manticoreResult->next(); |
||
81 | } |
||
82 | |||
83 | // we now need to standardize the output returned |
||
84 | |||
85 | $searchResults = new SearchResults(); |
||
86 | $searchResults->setRecords($ssResult); |
||
87 | $searchResults->setPage($this->page); |
||
88 | $searchResults->setPageSize($this->pageSize); |
||
89 | $searchResults->setQuery($q); |
||
90 | $searchResults->setTotalNumberOfResults($manticoreResult->getTotal()); |
||
91 | |||
92 | $endTime = \microtime(true); |
||
93 | $delta = $endTime - $startTime; |
||
94 | $delta = \round(1000*$delta)/1000; |
||
95 | $searchResults->setTime($delta); |
||
96 | |||
97 | return $searchResults; |
||
98 | } |
||
244 |
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