@@ -208,8 +208,12 @@ public static function charAt($subject, $index)
208
208
*
209
209
* @param array|string $needles
210
210
*/
211
- public static function contains (string $ haystack , $ needles ): bool
211
+ public static function contains (string $ haystack , mixed $ needles, bool $ ignoreCase = false ): bool
212
212
{
213
+ if ($ ignoreCase ) {
214
+ return static ::containsIgnoreCase ($ haystack , $ needles );
215
+ }
216
+
213
217
foreach ((array ) $ needles as $ needle ) {
214
218
$ needle = (string ) $ needle ;
215
219
if ($ needle !== '' && str_contains ($ haystack , $ needle )) {
@@ -220,17 +224,33 @@ public static function contains(string $haystack, $needles): bool
220
224
return false ;
221
225
}
222
226
227
+ /**
228
+ * Determine if a given string contains a given substring regardless of case sensitivity.
229
+ *
230
+ * @param array|string $needles
231
+ */
232
+ public static function containsIgnoreCase (string $ haystack , $ needles ): bool
233
+ {
234
+ foreach ((array ) $ needles as $ needle ) {
235
+ $ needle = (string ) $ needle ;
236
+ if ($ needle !== '' && stripos ($ haystack , $ needle ) !== false ) {
237
+ return true ;
238
+ }
239
+ }
240
+
241
+ return false ;
242
+ }
243
+
223
244
/**
224
245
* Determine if a given string contains all array values.
225
246
*
226
- * @param string $haystack
227
247
* @param string[] $needles
228
248
* @return bool
229
249
*/
230
- public static function containsAll ($ haystack , array $ needles )
250
+ public static function containsAll (string $ haystack , array $ needles, bool $ ignoreCase = false )
231
251
{
232
252
foreach ($ needles as $ needle ) {
233
- if (! static ::contains ($ haystack , $ needle )) {
253
+ if (! static ::contains ($ haystack , $ needle, $ ignoreCase )) {
234
254
return false ;
235
255
}
236
256
}
0 commit comments