Wrapper   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 14
c 3
b 0
f 0
dl 0
loc 25
ccs 14
cts 14
cp 1
rs 10
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B wrap() 0 23 8
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Conia\Boiler;
6
7
use Traversable;
8
9
class Wrapper
10
{
11 54
    public static function wrap(mixed $value): mixed
12
    {
13 54
        if (is_scalar($value) && !is_string($value)) {
14 11
            return $value;
15
        }
16 51
        if (is_string($value)) {
17 42
            return new Value($value);
18
        }
19 23
        if ($value instanceof ValueInterface) {
20
            // Don't wrap already wrapped values again
21 1
            return $value;
22
        }
23 22
        if (is_array($value)) {
24 7
            return new ArrayValue($value);
25
        }
26 19
        if ($value instanceof Traversable) {
27 6
            return new IteratorValue($value);
28
        }
29 16
        if (is_null($value)) {
30 2
            return null;
31
        }
32
33 15
        return new Value($value);
34
    }
35
}
36