TokenMap final class
Minn\Html\TokenMap · public/minn/src/Minn/Html/TokenMap.php · 87 lines
A map from words to replacements that reads the longest word at a place in a text (as character reference names are read): words shorter than the key length stand alone, the others are grouped by their first bytes, longest first.
Constants and properties
| private | array $small | |
| private | array $groups | |
| private | readonly int $keyLength | Promoted from the constructor. |
Public
| new | __construct(array $mappings, int $keyLength)# |
| |||
| method | keyLength(): int# | How many leading bytes group the words. | |||
| method | contains(string $word, string $caseSensitivity): bool# | Whether the word is in the map ("case-sensitive" or "ascii-case-insensitive"). | |||
| method | read(string $text, int $offset, string $caseSensitivity): ?array# | The replacement for the longest word at $offset, and the word's length; null when none starts there. @return array{0: string, 1: int}|null | |||
| method | toArray(): array# | Every word and its replacement: the short words first, then each group longest first. @return array<string, string> |
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | same(string $a, string $b, string $caseSensitivity): bool# |
Nothing matches.