Passed
Push — master ( 4b3d26...06dcf5 )
by Enjoys
12:36 queued 13s
created

Helper::scalarValueToString()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
6
namespace Enjoys\Dotenv;
7
8
9
final class Helper
10
{
11 28
    public static function scalarValueToString(string|bool|int|float|null $value): string
12
    {
13 28
        if (gettype($value) === 'boolean') {
14 6
            return $value ? 'true' : 'false';
15
        }
16 25
        return (string)$value;
17
    }
18
19 12
    public static function castType(string|bool|int|float|null $value): string|bool|int|float|null
20
    {
21 12
        if (gettype($value) !== 'string') {
22
            return $value;
23
        }
24 12
        return (new ValueTypecasting($value))->getCastValue();
25
    }
26
}
27