1 | <?php |
||
2 | |||
3 | namespace Mdiyakov\DoctrineSolrBundle\Query\Suggest\Result; |
||
4 | |||
5 | class FieldResult |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var string |
||
10 | */ |
||
11 | private $entityFieldName; |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $initialTerm; |
||
17 | |||
18 | /** |
||
19 | * @var SuggestionResult[] |
||
20 | */ |
||
21 | private $suggestions = []; |
||
22 | |||
23 | /** |
||
24 | * FieldResult constructor. |
||
25 | * @param string $entityFieldName |
||
26 | * @param string $initialTerm |
||
27 | * @param [][] $suggestions |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
28 | */ |
||
29 | public function __construct($entityFieldName, $initialTerm, array $suggestions) |
||
30 | { |
||
31 | $this->entityFieldName = $entityFieldName; |
||
32 | $this->initialTerm = $initialTerm; |
||
33 | |||
34 | foreach ($suggestions as $suggestion) { |
||
35 | $this->suggestions[] = new SuggestionResult($suggestion['term'], $suggestion['weight'], $suggestion['payload']); |
||
36 | } |
||
37 | |||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return SuggestionResult[] |
||
42 | */ |
||
43 | public function getSuggestions() |
||
44 | { |
||
45 | return $this->suggestions ? $this->suggestions : []; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return string |
||
50 | */ |
||
51 | public function getInitialTerm() |
||
52 | { |
||
53 | return $this->initialTerm; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | public function getEntityFieldName() |
||
60 | { |
||
61 | return $this->entityFieldName; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return int |
||
66 | */ |
||
67 | public function getCount() |
||
68 | { |
||
69 | return count($this->suggestions); |
||
70 | } |
||
71 | } |