Conditions | 3 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types = 1); |
||
17 | public function suggest(string $q, int $limit = 5): SuggesterResults |
||
18 | { |
||
19 | $result = new SuggesterResults(); |
||
20 | switch ($q) { |
||
21 | case 'webmister': |
||
22 | $result->setResults(['webmaster']); |
||
23 | |||
24 | break; |
||
25 | } |
||
26 | |||
27 | $suggestions = $result->getResults(); |
||
28 | if (\sizeof($suggestions) > $limit) { |
||
29 | $suggestions = \array_slice($result, 0, $limit); |
||
|
|||
30 | $result->setResults($suggestions); |
||
31 | } |
||
32 | |||
33 | $result->setQuery($q); |
||
34 | $result->setLimit($limit); |
||
35 | $result->setIndex('unit_test_index'); |
||
36 | |||
37 | return $result; |
||
38 | } |
||
40 |