Conditions | 5 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 6.4222 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5365 | public static function rtrim(string $str = '', string $chars = null): string |
||
5366 | { |
||
5367 | 21 | if ($str === '') { |
|
5368 | 3 | return ''; |
|
5369 | } |
||
5370 | |||
5371 | 20 | if (self::$SUPPORT['mbstring'] === true) { |
|
5372 | 20 | if ($chars !== null) { |
|
5373 | /** @noinspection PregQuoteUsageInspection */ |
||
5374 | 9 | $chars = \preg_quote($chars); |
|
5375 | 9 | $pattern = "[${chars}]+$"; |
|
5376 | } else { |
||
5377 | 14 | $pattern = '[\\s]+$'; |
|
5378 | } |
||
5379 | |||
5380 | 20 | return (string) \mb_ereg_replace($pattern, '', $str); |
|
5381 | } |
||
5382 | |||
5383 | if ($chars !== null) { |
||
5384 | $chars = \preg_quote($chars, '/'); |
||
5385 | $pattern = "[${chars}]+$"; |
||
5386 | } else { |
||
5387 | $pattern = '[\\s]+$'; |
||
5388 | } |
||
5389 | |||
5390 | return self::regex_replace($str, $pattern, ''); |
||
5391 | } |
||
13694 |