pure_php_templates/lib/SkinString.php
Evgeny Zinoviev 6c081f3aff initial
2022-07-07 20:31:22 +03:00

21 lines
590 B
PHP

<?php
class SkinString implements Stringable {
protected SkinStringModificationType $modType;
public function __construct(protected string $string) {}
public function setModType(SkinStringModificationType $modType) {
$this->modType = $modType;
}
public function __toString(): string {
return match ($this->modType) {
SkinStringModificationType::HTML => htmlspecialchars($this->string, ENT_QUOTES, 'UTF-8'),
SkinStringModificationType::URL => urlencode($this->string),
default => $this->string,
};
}
}