@@ -88,10 +88,40 @@ public static function has(string $string, $needle): bool
88
88
}
89
89
}
90
90
}
91
-
92
91
return false ;
93
92
}
94
93
94
+ /**
95
+ * @param string $string
96
+ * @param string|array $needle
97
+ * @return bool
98
+ */
99
+ public static function containsAll (string $ string , $ needle ): bool
100
+ {
101
+ return self ::hasAll ($ string , $ needle );
102
+ }
103
+
104
+ /**
105
+ * @param string $string
106
+ * @param string|array $needle
107
+ * @return bool
108
+ */
109
+ public static function hasAll (string $ string , $ needle ): bool
110
+ {
111
+ if (is_string ($ needle )) {
112
+ return str_contains ($ string , $ needle );
113
+ }
114
+
115
+ if (is_array ($ needle )) {
116
+ foreach ((array )$ needle as $ item ) {
117
+ if (!str_contains ($ string , $ item )) {
118
+ return false ;
119
+ }
120
+ }
121
+ }
122
+ return true ;
123
+ }
124
+
95
125
/**
96
126
* Alias of the `ihas()`
97
127
*
@@ -124,10 +154,32 @@ public static function ihas(string $string, $needle): bool
124
154
}
125
155
}
126
156
}
127
-
128
157
return false ;
129
158
}
130
159
160
+ /**
161
+ * Check all substr must in the haystack, will ignore case
162
+ *
163
+ * @param string $haystack
164
+ * @param string|array $needle
165
+ * @return bool
166
+ */
167
+ public static function iHasAll (string $ haystack , $ needle ): bool
168
+ {
169
+ if (is_string ($ needle )) {
170
+ return stripos ($ haystack , $ needle ) !== false ;
171
+ }
172
+
173
+ if (is_array ($ needle )) {
174
+ foreach ((array )$ needle as $ item ) {
175
+ if (stripos ($ haystack , $ item ) === false ) {
176
+ return false ;
177
+ }
178
+ }
179
+ }
180
+ return true ;
181
+ }
182
+
131
183
/**
132
184
* Alias of the `self::strpos()`
133
185
*
0 commit comments