Conditions | 8 |
Paths | 7 |
Total Lines | 29 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 8.0291 |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
6058 | 46 | public static function str_contains_any( |
|
6059 | string $haystack, |
||
6060 | array $needles, |
||
6061 | bool $case_sensitive = true |
||
6062 | ): bool { |
||
6063 | 46 | if ($haystack === '' || $needles === []) { |
|
6064 | 1 | return false; |
|
6065 | } |
||
6066 | |||
6067 | /** @noinspection LoopWhichDoesNotLoopInspection */ |
||
6068 | 45 | foreach ($needles as &$needle) { |
|
6069 | 45 | if (!$needle) { |
|
6070 | continue; |
||
6071 | } |
||
6072 | |||
6073 | 45 | if ($case_sensitive) { |
|
6074 | 25 | if (\strpos($haystack, $needle) !== false) { |
|
6075 | 14 | return true; |
|
6076 | } |
||
6077 | |||
6078 | 13 | continue; |
|
6079 | } |
||
6080 | |||
6081 | 20 | if (\mb_stripos($haystack, $needle) !== false) { |
|
6082 | 20 | return true; |
|
6083 | } |
||
6084 | } |
||
6085 | |||
6086 | 19 | return false; |
|
6087 | } |
||
14614 |