Conditions | 6 |
Paths | 5 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 9.7518 |
Changes | 0 |
1 | <?php |
||
8598 | public static function str_substr_after_first_separator(string $str, string $separator, string $encoding = 'UTF-8'): string |
||
8599 | { |
||
8600 | 1 | if ($separator === '' || $str === '') { |
|
8601 | 1 | return ''; |
|
8602 | } |
||
8603 | |||
8604 | 1 | if ($encoding === 'UTF-8') { |
|
8605 | 1 | $offset = \mb_strpos($str, $separator); |
|
8606 | 1 | if ($offset === false) { |
|
8607 | 1 | return ''; |
|
8608 | } |
||
8609 | |||
8610 | 1 | return (string) \mb_substr( |
|
8611 | 1 | $str, |
|
8612 | 1 | $offset + (int) \mb_strlen($separator) |
|
8613 | ); |
||
8614 | } |
||
8615 | |||
8616 | $offset = self::strpos($str, $separator, 0, $encoding); |
||
8617 | if ($offset === false) { |
||
8618 | return ''; |
||
8619 | } |
||
8620 | |||
8621 | return (string) \mb_substr( |
||
8622 | $str, |
||
8623 | $offset + (int) self::strlen($separator, $encoding), |
||
8624 | null, |
||
8625 | $encoding |
||
8626 | ); |
||
14700 |