Completed
Push — master ( a3b778...66a6dd )
by Sérgio
03:37
created

dropwhile.php ➔ dropwhile()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 21
Code Lines 11

Duplication

Lines 21
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 21
loc 21
rs 9.3142
1
<?php
2
3
namespace Sergiors\Functional;
4
5
const dropwhile = __NAMESPACE__.'\dropwhile';
6
7
/**
8
 * @author Sérgio Rafael Siqueira <[email protected]>
9
 *
10
 * @return array
11
 */
12 View Code Duplication
function dropwhile(/* ...$args */)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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