Conditions | 6 |
Paths | 5 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 9.7518 |
Changes | 0 |
1 | <?php |
||
8030 | public static function str_substr_after_first_separator(string $str, string $separator, string $encoding = 'UTF-8'): string |
||
8031 | { |
||
8032 | 1 | if ($separator === '' || $str === '') { |
|
8033 | 1 | return ''; |
|
8034 | } |
||
8035 | |||
8036 | 1 | if ($encoding === 'UTF-8') { |
|
8037 | 1 | $offset = \mb_strpos($str, $separator); |
|
8038 | 1 | if ($offset === false) { |
|
8039 | 1 | return ''; |
|
8040 | } |
||
8041 | |||
8042 | 1 | return (string) \mb_substr( |
|
8043 | 1 | $str, |
|
8044 | 1 | $offset + (int) \mb_strlen($separator) |
|
8045 | ); |
||
8046 | } |
||
8047 | |||
8048 | $offset = self::strpos($str, $separator, 0, $encoding); |
||
8049 | if ($offset === false) { |
||
8050 | return ''; |
||
8051 | } |
||
8052 | |||
8053 | return (string) \mb_substr( |
||
8054 | $str, |
||
8055 | $offset + (int) self::strlen($separator, $encoding), |
||
8056 | null, |
||
8057 | $encoding |
||
8058 | ); |
||
13694 |