dropwhile.php ➔ dropwhile()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 21
Code Lines 11

Duplication

Lines 21
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 3

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
ccs 10
cts 10
cp 1
crap 3
rs 9.3142
1
<?php
2
3
namespace Sergiors\Functional;
4
5
const dropwhile = '\Sergiors\Functional\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 2
    $args = func_get_args();
15
16
    $dropwhile = function (callable $condition, array $xss) {
17 2
        if ([] === $xss) {
18 1
            return [];
19
        }
20
21 2
        $head = head($xss);
22 2
        $tail = tail($xss);
23
24 2
        if ($condition($head)) {
25 2
            return dropwhile($condition, $tail);
26
        }
27
28 1
        return $xss;
29 2
    };
30
31 2
    return call_user_func_array(partial($dropwhile), $args);
32
}
33