Total Complexity | 6 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types = 1); |
||
16 | class BulkIndexer implements \Suilven\FreeTextSearch\Interfaces\BulkIndexer |
||
17 | { |
||
18 | |||
19 | /** @var string */ |
||
20 | private static $indexName; |
||
21 | |||
22 | /** @var array<string, (string|int|float|bool)>|null */ |
||
23 | private static $payload = []; |
||
24 | |||
25 | |||
26 | public function addDataObject(DataObject $dataObject): void |
||
27 | { |
||
28 | $helper = new IndexingHelper(); |
||
29 | |||
30 | $payload = $helper->getFieldsToIndex($dataObject); |
||
31 | |||
32 | // as we are not indexing against a real free text search engine, add the ID into the payload for testing |
||
33 | $payload['ID'] = $dataObject->ID; |
||
34 | self::$payload[] = $payload; |
||
35 | } |
||
36 | |||
37 | |||
38 | public function indexDataObjects(): void |
||
39 | { |
||
40 | // noop - this is a mock, so no implementation required |
||
41 | } |
||
42 | |||
43 | |||
44 | public function setIndex(string $newIndex): void |
||
45 | { |
||
46 | self::$indexName = $newIndex; |
||
47 | } |
||
48 | |||
49 | |||
50 | public static function getIndexName(): string |
||
51 | { |
||
52 | return self::$indexName; |
||
53 | } |
||
54 | |||
55 | |||
56 | /** @return array<string, (string|int|float|bool)>|null */ |
||
57 | public static function getIndexedPayload(): ?array |
||
60 | } |
||
61 | |||
62 | |||
63 | public static function resetIndexedPayload(): void |
||
66 | } |
||
67 | } |
||
68 |