1 | <?php |
||||||
2 | /** |
||||||
3 | * Trait SearchResultSetTrait|Firesphere\SearchBackend\Traits\SearchResultSetTrait Setters for |
||||||
4 | * {@link \Firesphere\SearchBackend\Interfaces\SearchResultInterface} |
||||||
5 | * |
||||||
6 | * @package Firesphere\Search\Backend |
||||||
7 | * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo |
||||||
8 | * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy |
||||||
9 | */ |
||||||
10 | |||||||
11 | namespace Firesphere\SearchBackend\Traits; |
||||||
12 | |||||||
13 | use Firesphere\SearchBackend\Interfaces\SearchResultInterface; |
||||||
14 | use SilverStripe\View\ArrayData; |
||||||
15 | use Solarium\Component\Result\FacetSet; |
||||||
0 ignored issues
–
show
|
|||||||
16 | use stdClass; |
||||||
17 | |||||||
18 | /** |
||||||
19 | * Trait SearchResultSetTrait |
||||||
20 | * |
||||||
21 | * Getters for search results to keep the {@link SearchResultInterface} class clean. |
||||||
22 | * |
||||||
23 | * @package Firesphere\Search\Backend |
||||||
24 | */ |
||||||
25 | trait SearchResultSetTrait |
||||||
26 | { |
||||||
27 | /** |
||||||
28 | * @var int Total items in result |
||||||
29 | */ |
||||||
30 | protected $totalItems = 0; |
||||||
31 | /** |
||||||
32 | * @var ArrayData Facets |
||||||
33 | */ |
||||||
34 | protected $facets; |
||||||
35 | |||||||
36 | /** |
||||||
37 | * @var array|stdClass[] Highlighted items |
||||||
38 | */ |
||||||
39 | protected $highlight; |
||||||
40 | |||||||
41 | /** |
||||||
42 | * Set the highlighted items |
||||||
43 | * |
||||||
44 | * @param $highlight |
||||||
45 | * @return SearchResultInterface |
||||||
46 | */ |
||||||
47 | public function setHighlight($highlights): SearchResultInterface |
||||||
48 | { |
||||||
49 | $this->highlight = $highlights; |
||||||
50 | |||||||
51 | return $this; |
||||||
0 ignored issues
–
show
|
|||||||
52 | } |
||||||
53 | |||||||
54 | /** |
||||||
55 | * Set the total amount of results |
||||||
56 | * |
||||||
57 | * @param $count |
||||||
58 | * @return self |
||||||
59 | */ |
||||||
60 | public function setTotalItems($count): SearchResultInterface |
||||||
61 | { |
||||||
62 | $this->totalItems = $count; |
||||||
63 | |||||||
64 | return $this; |
||||||
0 ignored issues
–
show
|
|||||||
65 | } |
||||||
66 | |||||||
67 | |||||||
68 | /** |
||||||
69 | * Set the facets to build |
||||||
70 | * |
||||||
71 | * @param stdClass|FacetSet $facets |
||||||
72 | * @return self |
||||||
73 | */ |
||||||
74 | public function setFacets($facets): self |
||||||
75 | { |
||||||
76 | $this->facets = $this->buildFacets($facets); |
||||||
77 | |||||||
78 | return $this; |
||||||
79 | } |
||||||
80 | |||||||
81 | |||||||
82 | /** |
||||||
83 | * Build the given list of key-value pairs in to a SilverStripe useable array |
||||||
84 | * |
||||||
85 | * @param stdClass|FacetSet $facets |
||||||
86 | * @return ArrayData |
||||||
87 | */ |
||||||
88 | protected function buildFacets($facets): ArrayData |
||||||
89 | { |
||||||
90 | $facetArray = []; |
||||||
91 | if ($facets) { |
||||||
92 | $facetTypes = $this->index->getFacetFields(); |
||||||
93 | // Loop all available facet fields by type |
||||||
94 | foreach ($facetTypes as $class => $options) { |
||||||
95 | $facetArray = $this->createFacet($facets, $options, $class, $facetArray); |
||||||
0 ignored issues
–
show
It seems like
createFacet() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
96 | } |
||||||
97 | } |
||||||
98 | |||||||
99 | // Return an ArrayList of the results |
||||||
100 | return ArrayData::create($facetArray); |
||||||
101 | } |
||||||
102 | } |
||||||
103 |
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