Conditions | 6 |
Paths | 8 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
6806 | 17 | public static function str_ireplace_beginning(string $str, string $search, string $replacement): string |
|
6807 | { |
||
6808 | 17 | if ($str === '') { |
|
6809 | 4 | if ($replacement === '') { |
|
6810 | 2 | return ''; |
|
6811 | } |
||
6812 | |||
6813 | 2 | if ($search === '') { |
|
6814 | 2 | return $replacement; |
|
6815 | } |
||
6816 | } |
||
6817 | |||
6818 | 13 | if ($search === '') { |
|
6819 | 2 | return $str . $replacement; |
|
6820 | } |
||
6821 | |||
6822 | 11 | $searchLength = \strlen($search); |
|
6823 | 11 | if (\strncasecmp($str, $search, $searchLength) === 0) { |
|
6824 | 10 | return $replacement . \substr($str, $searchLength); |
|
6825 | } |
||
6826 | |||
6827 | 1 | return $str; |
|
6828 | } |
||
14792 |