Code Duplication    Length = 21-21 lines in 2 locations

src/dropwhile.php 1 location

@@ 12-32 (lines=21) @@
9
 *
10
 * @return array
11
 */
12
function dropwhile(/* ...$args */)
13
{
14
    $args = func_get_args();
15
16
    $dropwhile = function (callable $condition, array $xss) {
17
        if ([] === $xss) {
18
            return [];
19
        }
20
21
        $head = head($xss);
22
        $tail = tail($xss);
23
24
        if ($condition($head)) {
25
            return dropwhile($condition, $tail);
26
        }
27
28
        return $xss;
29
    };
30
31
    return call_user_func_array(partial($dropwhile), $args);
32
}
33

src/takewhile.php 1 location

@@ 11-31 (lines=21) @@
8
 *
9
 * @return array
10
 */
11
function takewhile(/* ...$args */)
12
{
13
    $args = func_get_args();
14
15
    $takewhile = function (callable $condition, array $xss) {
16
        if ([] === $xss) {
17
            return [];
18
        }
19
20
        $head = head($xss);
21
        $tail = tail($xss);
22
23
        if ($condition($head)) {
24
            return array_merge([$head], takewhile($condition, $tail));
25
        }
26
27
        return [];
28
    };
29
30
    return call_user_func_array(partial($takewhile), $args);
31
}
32