Conditions | 6 |
Paths | 8 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6254 | 17 | public static function str_ireplace_ending(string $str, string $search, string $replacement): string |
|
6255 | { |
||
6256 | 17 | if ($str === '') { |
|
6257 | 4 | if ($replacement === '') { |
|
6258 | 2 | return ''; |
|
6259 | } |
||
6260 | |||
6261 | 2 | if ($search === '') { |
|
6262 | 2 | return $replacement; |
|
6263 | } |
||
6264 | } |
||
6265 | |||
6266 | 13 | if ($search === '') { |
|
6267 | 2 | return $str . $replacement; |
|
6268 | } |
||
6269 | |||
6270 | 11 | if (\stripos($str, $search, \strlen($str) - \strlen($search)) !== false) { |
|
6271 | 9 | $str = \substr($str, 0, -\strlen($search)) . $replacement; |
|
6272 | } |
||
6273 | |||
6274 | 11 | return $str; |
|
6275 | } |
||
13693 |