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 |
||
6228 | 17 | public static function str_ireplace_ending(string $str, string $search, string $replacement): string |
|
6229 | { |
||
6230 | 17 | if ($str === '') { |
|
6231 | 4 | if ($replacement === '') { |
|
6232 | 2 | return ''; |
|
6233 | } |
||
6234 | |||
6235 | 2 | if ($search === '') { |
|
6236 | 2 | return $replacement; |
|
6237 | } |
||
6238 | } |
||
6239 | |||
6240 | 13 | if ($search === '') { |
|
6241 | 2 | return $str . $replacement; |
|
6242 | } |
||
6243 | |||
6244 | 11 | if (\stripos($str, $search, \strlen($str) - \strlen($search)) !== false) { |
|
6245 | 9 | $str = \substr($str, 0, -\strlen($search)) . $replacement; |
|
6246 | } |
||
6247 | |||
6248 | 11 | return $str; |
|
6249 | } |
||
13666 |