flatten.php ➔ flatten()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 1
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Prelude;
6
7
const flatten = __NAMESPACE__.'\flatten';
8
9
function flatten(array $xss): array
10
{
11
    return \array_reduce($xss, function (array $prev, $x) {
12 1
        return \is_array($x)
13 1
            ? \array_merge($prev, flatten($x))
14 1
            : \array_merge($prev, [$x]);
15 1
    }, []);
16
}
17