Completed
Push — master ( 98b38a...fa405b )
by Woody
12s queued 10s
created

stringify()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Dryist;
4
5
/**
6
 * Create a modifier that constructs an object.
7
 *
8
 * @return callable (...) => new class(...)
9
 */
10
function make(string $class): callable
11
{
12
    return function (...$params) use ($class): object {
13 1
        return new $class(...$params);
14 1
    };
15
}
16
17
/**
18
 * Get the string representation of a value, without modifing nulls.
19
 *
20
 * @param mixed $value
21
 */
22
function stringify($value): ?string
23
{
24 1
    if ($value === null) {
25 1
        return null;
26
    }
27
28 1
    return (string) $value;
29
}
30