Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4.0312 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8015 | 19 | public static function str_starts_with(string $haystack, string $needle): bool |
|
8016 | { |
||
8017 | 19 | if ($needle === '') { |
|
8018 | 2 | return true; |
|
8019 | } |
||
8020 | |||
8021 | 19 | if ($haystack === '') { |
|
8022 | 1 | return false; |
|
8023 | } |
||
8024 | |||
8025 | 19 | if (\PHP_VERSION_ID >= 80000) { |
|
8026 | /** @phpstan-ignore-next-line - only for PHP8 */ |
||
8027 | 19 | return \str_starts_with($haystack, $needle); |
|
8028 | } |
||
8029 | |||
8030 | return \strncmp($haystack, $needle, \strlen($needle)) === 0; |
||
8031 | } |
||
13722 |