Total Complexity | 4 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | final class HtmlFilter |
||
20 | { |
||
21 | // Return the entire string as-is |
||
22 | public const ALLOW = 'allow'; |
||
23 | // Escape the entire string so any HTML/JS won't be interpreted as such |
||
24 | public const ESCAPE = 'escape'; |
||
25 | // Return an empty string |
||
26 | public const STRIP = 'strip'; |
||
27 | |||
28 | /** |
||
29 | * Runs the given HTML through the given filter |
||
30 | * |
||
31 | * @param string $html HTML input to be filtered |
||
32 | * @param string $filter One of the HtmlFilter constants |
||
33 | * |
||
34 | * @return string Filtered HTML |
||
35 | * |
||
36 | * @throws \InvalidArgumentException when an invalid $filter is given |
||
37 | * |
||
38 | * @psalm-pure |
||
39 | */ |
||
40 | 288 | public static function filter(string $html, string $filter): string |
|
54 |