Conditions | 5 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6.1384 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
4333 | 23 | public static function ltrim(string $str = '', string $chars = null): string |
|
4334 | { |
||
4335 | 23 | if ($str === '') { |
|
4336 | 3 | return ''; |
|
4337 | } |
||
4338 | |||
4339 | 22 | if (self::$SUPPORT['mbstring'] === true) { |
|
4340 | 22 | if ($chars !== null) { |
|
4341 | /** @noinspection PregQuoteUsageInspection */ |
||
4342 | 11 | $chars = \preg_quote($chars); |
|
4343 | 11 | $pattern = "^[${chars}]+"; |
|
4344 | } else { |
||
4345 | 14 | $pattern = '^[\\s]+'; |
|
4346 | } |
||
4347 | |||
4348 | 22 | return (string) \mb_ereg_replace($pattern, '', $str); |
|
4349 | } |
||
4350 | |||
4351 | if ($chars !== null) { |
||
4352 | $chars = \preg_quote($chars, '/'); |
||
4353 | $pattern = "^[${chars}]+"; |
||
4354 | } else { |
||
4355 | $pattern = '^[\\s]+'; |
||
4356 | } |
||
4357 | |||
4358 | return self::regex_replace($str, $pattern, ''); |
||
4359 | } |
||
13694 |