$this->parser =
$parser ??
new MastermindsParser();
} public function sanitize(string
$input): string
{ return $this->
sanitizeWithContext(W3CReference::CONTEXT_BODY,
$input);
} public function sanitizeFor(string
$element, string
$input): string
{ return $this->
sanitizeWithContext( W3CReference::CONTEXTS_MAP
[StringSanitizer::
htmlLower($element)] ?? W3CReference::CONTEXT_BODY,
$input );
} private function sanitizeWithContext(string
$context, string
$input): string
{ // Text context: early return with HTML encoding
if (W3CReference::CONTEXT_TEXT ===
$context) { return StringSanitizer::
encodeHtmlEntities($input);
}