indexOf.php ➔ indexOf()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 1
nop 1
dl 0
loc 10
ccs 5
cts 5
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 indexOf = __NAMESPACE__.'\indexOf';
8
9
function indexOf($x): \Closure
10
{
11
    return function (array $xs, bool $strict = false) use ($x): ?int {
12 2
        $pos = array_search($x, $xs, $strict);
13
14 2
        return false === $pos
15 1
            ? null
16 2
            : $pos;
17 2
    };
18
}
19