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 |
||
8102 | 1 | public static function str_substr_after_last_separator( |
|
8103 | string $str, |
||
8104 | string $separator, |
||
8105 | string $encoding = 'UTF-8' |
||
8106 | ): string { |
||
8107 | 1 | if ($separator === '' || $str === '') { |
|
8108 | 1 | return ''; |
|
8109 | } |
||
8110 | |||
8111 | 1 | if ($encoding === 'UTF-8') { |
|
8112 | 1 | $offset = \mb_strrpos($str, $separator); |
|
8113 | 1 | if ($offset === false) { |
|
8114 | 1 | return ''; |
|
8115 | } |
||
8116 | |||
8117 | 1 | return (string) \mb_substr( |
|
8118 | 1 | $str, |
|
8119 | 1 | $offset + (int) \mb_strlen($separator) |
|
8120 | ); |
||
8121 | } |
||
8122 | |||
8123 | $offset = self::strrpos($str, $separator, 0, $encoding); |
||
8124 | if ($offset === false) { |
||
8125 | return ''; |
||
8126 | } |
||
8127 | |||
8128 | return (string) self::substr( |
||
8129 | $str, |
||
8130 | $offset + (int) self::strlen($separator, $encoding), |
||
8131 | null, |
||
8132 | $encoding |
||
8133 | ); |
||
13706 |