Conditions | 6 |
Paths | 8 |
Total Lines | 24 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7424 | 17 | public static function str_replace_ending( |
|
7425 | string $str, |
||
7426 | string $search, |
||
7427 | string $replacement |
||
7428 | ): string { |
||
7429 | 17 | if ($str === '') { |
|
7430 | 4 | if ($replacement === '') { |
|
7431 | 2 | return ''; |
|
7432 | } |
||
7433 | |||
7434 | 2 | if ($search === '') { |
|
7435 | 2 | return $replacement; |
|
7436 | } |
||
7437 | } |
||
7438 | |||
7439 | 13 | if ($search === '') { |
|
7440 | 2 | return $str . $replacement; |
|
7441 | } |
||
7442 | |||
7443 | 11 | if (\strpos($str, $search, \strlen($str) - \strlen($search)) !== false) { |
|
7444 | 8 | $str = \substr($str, 0, -\strlen($search)) . $replacement; |
|
7445 | } |
||
7446 | |||
7447 | 11 | return $str; |
|
7448 | } |
||
13706 |