Conditions | 8 |
Paths | 7 |
Total Lines | 28 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 8.0291 |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
5720 | 46 | public static function str_contains_any( |
|
5721 | string $haystack, |
||
5722 | array $needles, |
||
5723 | bool $case_sensitive = true |
||
5724 | ): bool { |
||
5725 | 46 | if ($haystack === '' || $needles === []) { |
|
5726 | 1 | return false; |
|
5727 | } |
||
5728 | |||
5729 | 45 | foreach ($needles as &$needle) { |
|
5730 | 45 | if (!$needle) { |
|
5731 | continue; |
||
5732 | } |
||
5733 | |||
5734 | 45 | if ($case_sensitive) { |
|
5735 | 25 | if (\strpos($haystack, (string) $needle) !== false) { |
|
5736 | 14 | return true; |
|
5737 | } |
||
5738 | |||
5739 | 13 | continue; |
|
5740 | } |
||
5741 | |||
5742 | 20 | if (\mb_stripos($haystack, (string) $needle) !== false) { |
|
5743 | 12 | return true; |
|
5744 | } |
||
5745 | } |
||
5746 | |||
5747 | 19 | return false; |
|
5748 | } |
||
13722 |