Conditions | 6 |
Paths | 8 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6775 | public static function str_ireplace_ending(string $str, string $search, string $replacement): string |
||
6776 | { |
||
6777 | 17 | if ($str === '') { |
|
6778 | 4 | if ($replacement === '') { |
|
6779 | 2 | return ''; |
|
6780 | } |
||
6781 | |||
6782 | 2 | if ($search === '') { |
|
6783 | 2 | return $replacement; |
|
6784 | } |
||
6785 | } |
||
6786 | |||
6787 | 13 | if ($search === '') { |
|
6788 | 2 | return $str . $replacement; |
|
6789 | } |
||
6790 | |||
6791 | 11 | if (\stripos($str, $search, \strlen($str) - \strlen($search)) !== false) { |
|
6792 | 9 | $str = \substr($str, 0, -\strlen($search)) . $replacement; |
|
6793 | } |
||
6794 | |||
6795 | 11 | return $str; |
|
6796 | } |
||
14578 |