CanBeNull   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 10
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A or() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Hydration\Mapping\Simple\Type;
5
6
use Stratadox\Hydration\Mapping\Composite\CompositeMapping;
7
use Stratadox\Hydration\Mapping\Composite\ConditionalMapping;
8
use Stratadox\Hydration\Mapping\Primitive\NullCheck;
9
use Stratadox\Hydration\Mapping\Primitive\NullMapping;
10
use Stratadox\HydrationMapping\Mapping;
11
12
final class CanBeNull
13
{
14
    public static function or(Mapping $mapping): Mapping
15
    {
16
        return CompositeMapping::either(
17
            ConditionalMapping::ensureThat(
18
                NullCheck::passes(),
19
                NullMapping::inProperty($mapping->name())
20
            ),
21
            $mapping
22
        );
23
    }
24
}
25