xref: /dokuwiki/inc/Search/Collection/LookupCollection.php (revision ede4646658cf51245060332d97a319a39c788ea1)
1<?php
2
3namespace dokuwiki\Search\Collection;
4
5/**
6 * Abstract collection for lookup-based indexes
7 *
8 * In a lookup collection each token appears at most once per entity (frequency is always 1).
9 * Internally the same mechanisms as FrequencyCollection are used; only the way tokens are
10 * processed on input differs (deduplication instead of counting).
11 *
12 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
13 * @author Andreas Gohr <andi@splitbrain.org>
14 */
15abstract class LookupCollection extends AbstractCollection
16{
17    /** @inheritdoc */
18    protected function countTokens(array $tokens): array
19    {
20        return array_fill_keys(array_unique($tokens), 1);
21    }
22}
23