| Total Complexity | 3 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types = 1); |
||
| 18 | class Searcher extends \Suilven\FreeTextSearch\Base\Searcher |
||
| 19 | { |
||
| 20 | /** @return array<string,array<string,string>> */ |
||
| 21 | public function search(?string $q): SearchResults |
||
| 22 | { |
||
| 23 | $result = new SearchResults(); |
||
| 24 | switch ($q) { |
||
| 25 | case 'Fish': |
||
| 26 | $records = [ |
||
| 27 | [ |
||
| 28 | 'Title' => 'Fishing in New Zealand', |
||
| 29 | ], |
||
| 30 | ]; |
||
| 31 | $recordsList = new ArrayList($records); |
||
| 32 | $result->setRecords($recordsList); |
||
| 33 | |||
| 34 | $result->setTime(0.017); |
||
| 35 | |||
| 36 | $result->setPageSize(10); |
||
| 37 | $result->setPage(1); |
||
| 38 | |||
| 39 | $result->setIndex('unit_test_index'); |
||
| 40 | $result->setSuggestions(['fush']); |
||
| 41 | |||
| 42 | |||
| 43 | $highlights = ['Title' => [ |
||
| 44 | '<b>Fish</b>ing in New Zealand', |
||
| 45 | ], |
||
| 46 | ]; |
||
| 47 | |||
| 48 | $result->Highlights = $highlights; |
||
|
|
|||
| 49 | } |
||
| 50 | |||
| 51 | return $result; |
||
| 52 | } |
||
| 53 | |||
| 54 | |||
| 55 | /** @param \SilverStripe\ORM\DataObject $dataObject a dataObject relevant to the index */ |
||
| 56 | public function searchForSimilar(DataObject $dataObject): SearchResults |
||
| 59 | } |
||
| 60 | } |
||
| 61 |