@@ -88,10 +88,40 @@ public static function has(string $string, $needle): bool
8888 }
8989 }
9090 }
91-
9291 return false ;
9392 }
9493
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+
95125 /**
96126 * Alias of the `ihas()`
97127 *
@@ -124,10 +154,32 @@ public static function ihas(string $string, $needle): bool
124154 }
125155 }
126156 }
127-
128157 return false ;
129158 }
130159
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+
131183 /**
132184 * Alias of the `self::strpos()`
133185 *
0 commit comments