Detector Authoring
Detector Authoring
A detector should be narrow, deterministic, Unicode-aware, and covered by fixtures. Checksum identifiers should validate checksums before returning detections.
final class ExampleDetector implements Detector
{
public function name(): string
{
return 'example';
}
public function detect(string $text): array
{
return [];
}
}
- Name the detector
Choose a stable lowercase id. - Match candidates
Use bounded patterns and Unicode flags. - Validate
Reject checksum failures and sentinel values. - Return spans
Preserve original offset and length. - Test overlap
Add tests against adjacent, nested, and multi-byte text.