Completed
Pull Request — master (#4)
by
unknown
04:46
created

helpers.php ➔ enum_if()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 3.1852

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 4
ccs 1
cts 3
cp 0.3333
crap 3.1852
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
use DavidIanBonner\Enumerated\Enum;
6
7 1
if (!function_exists('enum_if')) {
8
    function enum_if($data, string $className, $default = null): ?Enum
9
    {
10 2
        return $data ? new $className($data) : $default;
11
    }
12
}
13