Code Duplication    Length = 20-20 lines in 4 locations

src/string.php 4 locations

@@ 157-176 (lines=20) @@
154
    }
155
}
156
157
if (!function_exists('ends_with_insensitive')) {
158
    /**
159
     * Determine if a given string ends with a given substring (case insensitive).
160
     *
161
     * @param  string $haystack
162
     * @param  string|array $needles
163
     * @return bool
164
     */
165
    function ends_with_insensitive($haystack, $needles)
166
    {
167
        if (isNullOrEmpty($haystack) || isNullOrEmpty($needles)) {
168
            return false;
169
        }
170
171
        $haystack = strtolower($haystack);
172
        $needles = strtolower($needles);
173
174
        return ends_with($haystack, $needles);
175
    }
176
}
177
178
if (!function_exists('starts_with')) {
179
    /**
@@ 250-269 (lines=20) @@
247
    }
248
}
249
250
if (!function_exists('str_contains_insensitive')) {
251
    /**
252
     * Determine if a given string contains a given substring (case insensitive).
253
     *
254
     * @param  string $haystack
255
     * @param  string|array $needles
256
     * @return bool
257
     */
258
    function str_contains_insensitive($haystack, $needles)
259
    {
260
        if (isNullOrEmpty($haystack) || isNullOrEmpty($needles)) {
261
            return false;
262
        }
263
264
        $haystack = strtolower($haystack);
265
        $needles = strtolower($needles);
266
267
        return str_contains($haystack, $needles);
268
    }
269
}
270
271
if (!function_exists('str_finish')) {
272
    /**
@@ 290-309 (lines=20) @@
287
    }
288
}
289
290
if (!function_exists('str_finish_insensitive')) {
291
    /**
292
     * Cap a string with a single instance of a given value (Case Insensitive).
293
     *
294
     * @param  string $value
295
     * @param  string $cap
296
     * @return string
297
     */
298
    function str_finish_insensitive($value, $cap)
299
    {
300
        if (isNullOrEmpty($value) || isNullOrEmpty($cap)) {
301
            return false;
302
        }
303
304
        $value = strtolower($value);
305
        $cap = strtolower($cap);
306
307
        return str_finish($value, $cap);
308
    }
309
}
310
311
if (!function_exists('str_is')) {
312
    /**
@@ 201-220 (lines=20) @@
198
    }
199
}
200
201
if (!function_exists('starts_with_insensitive')) {
202
    /**
203
     * Determine if a given string starts with a given substring (case insensitive).
204
     *
205
     * @param  string $haystack
206
     * @param  string|array $needles
207
     * @return bool
208
     */
209
    function starts_with_insensitive($haystack, $needles)
210
    {
211
        if (isNullOrEmpty($haystack) || (!is_array($needles) && isNullOrEmpty($needles))) {
212
            return false;
213
        }
214
215
        $haystack = strtolower($haystack);
216
        $needles = strtolower($needles);
217
218
        return starts_with($haystack, $needles);
219
    }
220
}
221
222
if (!function_exists('str_contains')) {
223
    /**