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

BooleanValue::withCustomTruths()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 7
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Hydration\Mapping\Property\Type;
5
6
use Stratadox\Hydration\Mapping\DifferentKey;
7
use Stratadox\Hydration\Mapping\Property\Keyed;
8
use Stratadox\Hydration\Mapping\Primitive\BooleanMapping;
9
use Stratadox\HydrationMapping\KeyedMapping;
10
11
final class BooleanValue
12
{
13
    public static function withCustomTruths(
14
        string $name,
15
        array $truths,
16
        array $falsehoods
17
    ): KeyedMapping {
18
        return Keyed::mapping($name,
19
            BooleanMapping::custom($name, $truths, $falsehoods)
20
        );
21
    }
22
23
    public static function withCustomTruthsAndKey(
24
        string $name,
25
        string $key,
26
        array $truths,
27
        array $falsehoods
28
    ): KeyedMapping {
29
        return Keyed::mapping($key, DifferentKey::use(
30
            $key,
31
            BooleanMapping::custom($name, $truths, $falsehoods)
32
        ));
33
    }
34
35
    public static function inProperty(string $name): KeyedMapping
36
    {
37
        return Keyed::mapping($name, BooleanMapping::inProperty($name));
38
    }
39
40
    public static function inPropertyWithDifferentKey(
41
        string $name,
42
        string $key
43
    ): KeyedMapping {
44
        return Keyed::mapping($key, DifferentKey::use(
45
            $key,
46
            BooleanMapping::inProperty($name))
47
        );
48
    }
49
}
50