Code Duplication    Length = 14-14 lines in 2 locations

src/list.php 2 locations

@@ 977-990 (lines=14) @@
974
 * @param  array $list
975
 * @return int
976
 */
977
function indexOf() {
978
    static $indexOf = false;
979
    $indexOf = $indexOf ?: curry(function($item, $list) {
980
        if (is_string($list)) {
981
            $index = strpos($list, $item);
982
        } else {
983
            $index = findIndex(equals($item), $list);
984
        }
985
        return (false === $index || null === $index)
986
            ? -1
987
            : $index;
988
    });
989
    return _apply($indexOf, func_get_args());
990
}
991
992
/**
993
 * Same as `indexOf` but returns the key/position/name of the last item/substring/attribute.
@@ 1010-1023 (lines=14) @@
1007
 * @param  array $list
1008
 * @return int
1009
 */
1010
function lastIndexOf() {
1011
    static $lastIndexOf = false;
1012
    $lastIndexOf = $lastIndexOf ?: curry(function($item, $list) {
1013
        if (is_string($list)) {
1014
            $index = strrpos($list, $item);
1015
        } else {
1016
            $index = findLastIndex(equals($item), $list);
1017
        }
1018
        return (false === $index || null === $index)
1019
            ? -1
1020
            : $index;
1021
    });
1022
    return _apply($lastIndexOf, func_get_args());
1023
}
1024
1025
/**
1026
 * Removes duplicates from a list.