Conditions | 4 |
Paths | 3 |
Total Lines | 25 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5259 | 12 | public static function remove_right( |
|
5260 | string $str, |
||
5261 | string $substring, |
||
5262 | string $encoding = 'UTF-8' |
||
5263 | ): string { |
||
5264 | 12 | if ($substring && \substr($str, -\strlen($substring)) === $substring) { |
|
5265 | 6 | if ($encoding === 'UTF-8') { |
|
5266 | 4 | return (string) \mb_substr( |
|
5267 | $str, |
||
5268 | 0, |
||
5269 | 4 | (int) \mb_strlen($str) - (int) \mb_strlen($substring) |
|
5270 | ); |
||
5271 | } |
||
5272 | |||
5273 | 2 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
|
5274 | |||
5275 | 2 | return (string) self::substr( |
|
5276 | $str, |
||
5277 | 0, |
||
5278 | 2 | (int) self::strlen($str, $encoding) - (int) self::strlen($substring, $encoding), |
|
5279 | $encoding |
||
5280 | ); |
||
5281 | } |
||
5282 | |||
5283 | 6 | return $str; |
|
5284 | } |
||
13722 |