Code Duplication    Length = 7-10 lines in 7 locations

src/common.php 1 location

@@ 80-86 (lines=7) @@
77
 * @param  mixed $data
78
 * @return boolean
79
 */
80
function is() {
81
    static $is = false;
82
    $is = $is ?: curry(function($type, $data) {
83
        return 'Any' == $type || type($data) == $type;
84
    });
85
    return _apply($is, func_get_args());
86
}
87
88
/**
89
 * Converts a variable to its string value.

src/list.php 4 locations

@@ 92-98 (lines=7) @@
89
 * @param  array $list
90
 * @return array
91
 */
92
function reduce() {
93
    static $reduce = false;
94
    $reduce = $reduce ?: curry(function($fn, $initial, $list){
95
        return array_reduce($list, $fn, $initial);
96
    });
97
    return _apply($reduce, func_get_args());
98
}
99
100
/**
101
 * Applies the callback to each item and returns the original list.
@@ 119-128 (lines=10) @@
116
 * @param  array $list
117
 * @return array
118
 */
119
function each() {
120
    static $each = false;
121
    $each = $each ?: curry(function($fn, $list){
122
        foreach ($list as $item) {
123
            apply($fn, [$item]);
124
        }
125
        return $list;
126
    });
127
    return _apply($each, func_get_args());
128
}
129
130
/**
131
 * Returns the first item of the given array or string.
@@ 922-928 (lines=7) @@
919
 * @param  array $list
920
 * @return mixed
921
 */
922
function find() {
923
    static $find = false;
924
    $find = $find ?: curry(function($predicate, $list) {
925
        return get(findIndex($predicate, $list), $list);
926
    });
927
    return _apply($find, func_get_args());
928
}
929
930
/**
931
 * Returns the last item satisfying the predicate in
@@ 945-951 (lines=7) @@
942
 * @param  array $list
943
 * @return mixed
944
 */
945
function findLast() {
946
    static $findLast = false;
947
    $findLast = $findLast ?: curry(function($predicate, $list) {
948
        return get(findLastIndex($predicate, $list), $list);
949
    });
950
    return _apply($findLast, func_get_args());
951
}
952
953
/**
954
 * Returns the index of an item/substring in a list/string.

src/operators.php 1 location

@@ 231-237 (lines=7) @@
228
 * @signature (a -> b) -> a -> a -> Boolean
229
 * @return [type] [description]
230
 */
231
function equalBy() {
232
    static $equalBy = false;
233
    $equalBy = $equalBy ?: curry(function($fn, $a, $b) {
234
        return equals($fn($a), $fn($b));
235
    });
236
    return _apply($equalBy, func_get_args());
237
}
238
239
/**
240
 * Returns `$a < $b`.

src/string.php 1 location

@@ 277-285 (lines=9) @@
274
 * @param  string $string
275
 * @return array
276
 */
277
function match() {
278
    static $match = false;
279
    $match = $match ?: curry(function($pattern, $string) {
280
        $results = [];
281
        preg_match_all($pattern, $string, $results);
282
        return $results[0];
283
    });
284
    return _apply($match, func_get_args());
285
}
286
287
/**
288
 * Curried version of `substr_count` with changed order of parameters,