@@ -208,8 +208,12 @@ public static function charAt($subject, $index)
208208 *
209209 * @param array|string $needles
210210 */
211- public static function contains (string $ haystack , $ needles ): bool
211+ public static function contains (string $ haystack , mixed $ needles, bool $ ignoreCase = false ): bool
212212 {
213+ if ($ ignoreCase ) {
214+ return static ::containsIgnoreCase ($ haystack , $ needles );
215+ }
216+
213217 foreach ((array ) $ needles as $ needle ) {
214218 $ needle = (string ) $ needle ;
215219 if ($ needle !== '' && str_contains ($ haystack , $ needle )) {
@@ -220,17 +224,33 @@ public static function contains(string $haystack, $needles): bool
220224 return false ;
221225 }
222226
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+
223244 /**
224245 * Determine if a given string contains all array values.
225246 *
226- * @param string $haystack
227247 * @param string[] $needles
228248 * @return bool
229249 */
230- public static function containsAll ($ haystack , array $ needles )
250+ public static function containsAll (string $ haystack , array $ needles, bool $ ignoreCase = false )
231251 {
232252 foreach ($ needles as $ needle ) {
233- if (! static ::contains ($ haystack , $ needle )) {
253+ if (! static ::contains ($ haystack , $ needle, $ ignoreCase )) {
234254 return false ;
235255 }
236256 }
0 commit comments