Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 4.3731 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7969 | public static function str_starts_with(string $haystack, string $needle): bool |
||
7970 | { |
||
7971 | 19 | if ($needle === '') { |
|
7972 | 2 | return true; |
|
7973 | } |
||
7974 | |||
7975 | 19 | if ($haystack === '') { |
|
7976 | return false; |
||
7977 | } |
||
7978 | |||
7979 | 19 | if (\PHP_VERSION_ID >= 80000) { |
|
7980 | /** @phpstan-ignore-next-line - only for PHP8 */ |
||
7981 | return \str_starts_with($haystack, $needle); |
||
7982 | } |
||
7983 | |||
7984 | 19 | return \strncmp($haystack, $needle, \strlen($needle)) === 0; |
|
7985 | } |
||
13694 |