Conditions | 6 |
Paths | 8 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
6219 | 17 | public static function str_ireplace_beginning(string $str, string $search, string $replacement): string |
|
6220 | { |
||
6221 | 17 | if ($str === '') { |
|
6222 | 4 | if ($replacement === '') { |
|
6223 | 2 | return ''; |
|
6224 | } |
||
6225 | |||
6226 | 2 | if ($search === '') { |
|
6227 | 2 | return $replacement; |
|
6228 | } |
||
6229 | } |
||
6230 | |||
6231 | 13 | if ($search === '') { |
|
6232 | 2 | return $str . $replacement; |
|
6233 | } |
||
6234 | |||
6235 | 11 | $searchLength = \strlen($search); |
|
6236 | 11 | if (\strncasecmp($str, $search, $searchLength) === 0) { |
|
6237 | 10 | return $replacement . \substr($str, $searchLength); |
|
6238 | } |
||
6239 | |||
6240 | 1 | return $str; |
|
6241 | } |
||
13694 |