Conditions | 6 |
Paths | 5 |
Total Lines | 31 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 8.5139 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8072 | 1 | public static function str_substr_after_last_separator( |
|
8073 | string $str, |
||
8074 | string $separator, |
||
8075 | string $encoding = 'UTF-8' |
||
8076 | ): string { |
||
8077 | 1 | if ($separator === '' || $str === '') { |
|
8078 | 1 | return ''; |
|
8079 | } |
||
8080 | |||
8081 | 1 | if ($encoding === 'UTF-8') { |
|
8082 | 1 | $offset = \mb_strrpos($str, $separator); |
|
8083 | 1 | if ($offset === false) { |
|
8084 | 1 | return ''; |
|
8085 | } |
||
8086 | |||
8087 | 1 | return (string) \mb_substr( |
|
8088 | 1 | $str, |
|
8089 | 1 | $offset + (int) \mb_strlen($separator) |
|
8090 | ); |
||
8091 | } |
||
8092 | |||
8093 | $offset = self::strrpos($str, $separator, 0, $encoding); |
||
8094 | if ($offset === false) { |
||
8095 | return ''; |
||
8096 | } |
||
8097 | |||
8098 | return (string) self::substr( |
||
8099 | $str, |
||
8100 | $offset + (int) self::strlen($separator, $encoding), |
||
8101 | null, |
||
8102 | $encoding |
||
8103 | ); |
||
13694 |