Code Duplication    Length = 11-11 lines in 2 locations

Str.php 2 locations

@@ 393-403 (lines=11) @@
390
     * @param   string|null $encoding   The encoding to use.
391
     * @return  int                     The index of the first occurrence if found, -1 otherwise.
392
     */
393
    public static function indexOf(string $haystack, string $needle, int $offset = 0, bool $strict = true, string $encoding = null) : int
394
    {
395
        $func     = $strict ? 'mb_strpos' : 'mb_stripos';
396
        $encoding = $encoding ?: static::encoding($haystack);
397
398
        if (false === $result = $func($haystack, $needle, $offset, $encoding)) {
399
            return -1;
400
        }
401
402
        return $result;
403
    }
404
405
    /**
406
     * Returns the index (0-indexed) of the last occurrence of $needle in the $haystack.
@@ 419-429 (lines=11) @@
416
     * @param   string  $encoding   The encoding to use.
417
     * @return  int                 The index of the last occurrence if found, -1 otherwise.
418
     */
419
    public static function indexOfLast(string $haystack, string $needle, int $offset = 0, bool $strict = true, string $encoding = null) : int
420
    {
421
        $func     = $strict ? 'mb_strrpos' : 'mb_strripos';
422
        $encoding = $encoding ?: static::encoding($haystack);
423
424
        if (false === $result = $func($haystack, $needle, $offset, $encoding)) {
425
            return -1;
426
        }
427
428
        return $result;
429
    }
430
431
    /**
432
     * Inserts the given $needle into the $haystack at the provided offset.