Conditions | 3 |
Paths | 2 |
Total Lines | 28 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
3151 | 9 | public static function htmlentities( |
|
3152 | string $str, |
||
3153 | int $flags = \ENT_COMPAT, |
||
3154 | string $encoding = 'UTF-8', |
||
3155 | bool $double_encode = true |
||
3156 | ): string { |
||
3157 | 9 | if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
|
3158 | 7 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
|
3159 | } |
||
3160 | |||
3161 | 9 | $str = \htmlentities( |
|
3162 | 9 | $str, |
|
3163 | 9 | $flags, |
|
3164 | 9 | $encoding, |
|
3165 | 9 | $double_encode |
|
3166 | ); |
||
3167 | |||
3168 | /** |
||
3169 | * PHP doesn't replace a backslash to its html entity since this is something |
||
3170 | * that's mostly used to escape characters when inserting in a database. Since |
||
3171 | * we're using a decent database layer, we don't need this shit and we're replacing |
||
3172 | * the double backslashes by its' html entity equivalent. |
||
3173 | * |
||
3174 | * https://github.com/forkcms/library/blob/master/spoon/filter/filter.php#L303 |
||
3175 | */ |
||
3176 | 9 | $str = \str_replace('\\', '\', $str); |
|
3177 | |||
3178 | 9 | return self::html_encode($str, true, $encoding); |
|
3179 | } |
||
13706 |