Conditions | 6 |
Paths | 5 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 9.1595 |
Changes | 0 |
1 | <?php |
||
8060 | 1 | public static function str_substr_after_first_separator(string $str, string $separator, string $encoding = 'UTF-8'): string |
|
8061 | { |
||
8062 | 1 | if ($separator === '' || $str === '') { |
|
8063 | 1 | return ''; |
|
8064 | } |
||
8065 | |||
8066 | 1 | if ($encoding === 'UTF-8') { |
|
8067 | 1 | $offset = \mb_strpos($str, $separator); |
|
8068 | 1 | if ($offset === false) { |
|
8069 | 1 | return ''; |
|
8070 | } |
||
8071 | |||
8072 | 1 | return (string) \mb_substr( |
|
8073 | 1 | $str, |
|
8074 | 1 | $offset + (int) \mb_strlen($separator) |
|
8075 | ); |
||
8076 | } |
||
8077 | |||
8078 | $offset = self::strpos($str, $separator, 0, $encoding); |
||
8079 | if ($offset === false) { |
||
8080 | return ''; |
||
8081 | } |
||
8082 | |||
8083 | return (string) \mb_substr( |
||
8084 | $str, |
||
8085 | $offset + (int) self::strlen($separator, $encoding), |
||
8086 | null, |
||
8087 | $encoding |
||
8088 | ); |
||
13706 |