Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8562 | public static function str_starts_with(string $haystack, string $needle): bool |
||
8563 | { |
||
8564 | if ($needle === '') { |
||
8565 | return true; |
||
8566 | } |
||
8567 | |||
8568 | if ($haystack === '') { |
||
8569 | return false; |
||
8570 | } |
||
8571 | |||
8572 | if (\PHP_VERSION_ID >= 80000) { |
||
8573 | /** @phpstan-ignore-next-line - only for PHP8 */ |
||
8574 | return \str_starts_with($haystack, $needle); |
||
8575 | } |
||
8576 | |||
8577 | return \strncmp($haystack, $needle, \strlen($needle)) === 0; |
||
8578 | } |
||
14796 |