Conditions | 5 |
Paths | 5 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6.1384 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5723 | 21 | public static function rtrim(string $str = '', string $chars = null): string |
|
5724 | { |
||
5725 | 21 | if ($str === '') { |
|
5726 | 3 | return ''; |
|
5727 | } |
||
5728 | |||
5729 | 20 | if (self::$SUPPORT['mbstring'] === true) { |
|
5730 | 20 | if ($chars !== null) { |
|
5731 | /** @noinspection PregQuoteUsageInspection */ |
||
5732 | 9 | $chars = \preg_quote($chars); |
|
5733 | 9 | $pattern = "[${chars}]+$"; |
|
5734 | } else { |
||
5735 | 14 | $pattern = '[\\s]+$'; |
|
5736 | } |
||
5737 | |||
5738 | /** @noinspection PhpComposerExtensionStubsInspection */ |
||
5739 | 20 | return (string) \mb_ereg_replace($pattern, '', $str); |
|
5740 | } |
||
5741 | |||
5742 | if ($chars !== null) { |
||
5743 | $chars = \preg_quote($chars, '/'); |
||
5744 | $pattern = "[${chars}]+$"; |
||
5745 | } else { |
||
5746 | $pattern = '[\\s]+$'; |
||
5747 | } |
||
5748 | |||
5749 | return self::regex_replace($str, $pattern, ''); |
||
5750 | } |
||
14812 |