Conditions | 6 |
Paths | 8 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
6265 | 17 | public static function str_ireplace_beginning(string $str, string $search, string $replacement): string |
|
6266 | { |
||
6267 | 17 | if ($str === '') { |
|
6268 | 4 | if ($replacement === '') { |
|
6269 | 2 | return ''; |
|
6270 | } |
||
6271 | |||
6272 | 2 | if ($search === '') { |
|
6273 | 2 | return $replacement; |
|
6274 | } |
||
6275 | } |
||
6276 | |||
6277 | 13 | if ($search === '') { |
|
6278 | 2 | return $str . $replacement; |
|
6279 | } |
||
6280 | |||
6281 | 11 | $searchLength = \strlen($search); |
|
6282 | 11 | if (\strncasecmp($str, $search, $searchLength) === 0) { |
|
6283 | 10 | return $replacement . \substr($str, $searchLength); |
|
6284 | } |
||
6285 | |||
6286 | 1 | return $str; |
|
6287 | } |
||
13722 |