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

HasManyNested::value()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
c 2
b 0
f 0
dl 0
loc 12
rs 9.9666
cc 3
nc 3
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Hydration\Mapping\Property\Relationship;
5
6
use Stratadox\Deserializer\Deserializer;
7
use Stratadox\Hydration\Mapping\DifferentKey;
8
use Stratadox\Hydration\Mapping\Nested;
9
use Stratadox\Hydration\Mapping\Property\Keyed;
10
use Stratadox\Hydration\Mapping\Relation\RelationCollectionMapping;
11
use Stratadox\HydrationMapping\KeyedMapping;
12
13
final class HasManyNested
14
{
15
    public static function inProperty(
16
        string $name,
17
        Deserializer $collection,
18
        Deserializer $item
19
    ): KeyedMapping {
20
        return Keyed::mapping($name, Nested::inKey(
21
            $name,
22
            RelationCollectionMapping::inProperty($name, $collection, $item)
23
        ));
24
    }
25
26
    public static function inPropertyWithDifferentKey(
27
        string $name,
28
        string $key,
29
        Deserializer $collection,
30
        Deserializer $item
31
    ): KeyedMapping {
32
        return Keyed::mapping($key, DifferentKey::use(
33
            $key,
34
            self::inProperty($name, $collection, $item)
35
        ));
36
    }
37
}
38