Passed
Push — master ( 01c6a8...5a4258 )
by Jesse
09:00
created

CanBeFloat::value()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 12
rs 9.9666
c 0
b 0
f 0
cc 3
nc 3
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Hydration\Mapping\Property\Type;
5
6
use Stratadox\Hydration\Mapping\Composite\CompositeMapping;
7
use Stratadox\Hydration\Mapping\Composite\ConditionalMapping;
8
use Stratadox\Hydration\Mapping\Primitive\FloatCheck;
9
use Stratadox\Hydration\Mapping\Primitive\FloatMapping;
10
use Stratadox\Hydration\Mapping\Property\Keyed;
11
use Stratadox\HydrationMapping\KeyedMapping;
12
13
final class CanBeFloat
14
{
15
    public static function or(KeyedMapping $mapping): KeyedMapping
16
    {
17
        return Keyed::mapping($mapping->key(),
18
            CompositeMapping::either(
19
                ConditionalMapping::ensureThat(FloatCheck::passes(), FloatMapping::inProperty($mapping->name())),
20
                $mapping
21
            )
22
        );
23
    }
24
}
25