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 |
||
4306 | 23 | public static function ltrim(string $str = '', string $chars = null): string |
|
4307 | { |
||
4308 | 23 | if ($str === '') { |
|
4309 | 3 | return ''; |
|
4310 | } |
||
4311 | |||
4312 | 22 | if (self::$SUPPORT['mbstring'] === true) { |
|
4313 | 22 | if ($chars !== null) { |
|
4314 | /** @noinspection PregQuoteUsageInspection */ |
||
4315 | 11 | $chars = \preg_quote($chars); |
|
4316 | 11 | $pattern = "^[${chars}]+"; |
|
4317 | } else { |
||
4318 | 14 | $pattern = '^[\\s]+'; |
|
4319 | } |
||
4320 | |||
4321 | 22 | return (string) \mb_ereg_replace($pattern, '', $str); |
|
4322 | } |
||
4323 | |||
4324 | if ($chars !== null) { |
||
4325 | $chars = \preg_quote($chars, '/'); |
||
4326 | $pattern = "^[${chars}]+"; |
||
4327 | } else { |
||
4328 | $pattern = '^[\\s]+'; |
||
4329 | } |
||
4330 | |||
4331 | return self::regex_replace($str, $pattern, ''); |
||
4332 | } |
||
13666 |