summaryrefslogtreecommitdiff
path: root/lib/SkinString.php
blob: ef43090f13d93c5714881fc3d6325ab0a8fc0bb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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,
        };
    }

}