aboutsummaryrefslogtreecommitdiff
path: root/src/Esc.php
blob: 5c290b65fbe01ce49daef1c502c6e1030cf9e503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php


namespace Micropoly;


class Esc
{
    public const HTML = 1;
    public const NL2BR = 2;
    public const HTML_WITH_BR = self::HTML | self::NL2BR;

    public static function e(string $s, int $flags = self::HTML): string
    {
        if ($flags & self::HTML)
            $s = htmlspecialchars($s);
        if ($flags & self::NL2BR)
            $s = nl2br($s);
        return $s;
    }
}