diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-07-07 20:31:22 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-07-07 20:31:22 +0300 |
commit | 6c081f3aff64689ed3b77bfeec1d2e0005fe5286 (patch) | |
tree | ceaeb1c9b235a7f701039d11da145bd18ae98be3 /lib/SkinString.php |
initial
Diffstat (limited to 'lib/SkinString.php')
-rw-r--r-- | lib/SkinString.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/SkinString.php b/lib/SkinString.php new file mode 100644 index 0000000..ef43090 --- /dev/null +++ b/lib/SkinString.php @@ -0,0 +1,21 @@ +<?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, + }; + } + +}
\ No newline at end of file |