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

HasManyProxies::value()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 13
rs 9.9332
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\Property\Keyed;
9
use Stratadox\Hydration\Mapping\Relation\NumberedProxyCollectionMapping;
10
use Stratadox\HydrationMapping\KeyedMapping;
11
use Stratadox\Proxy\ProxyFactory;
12
13
/**
14
 * Maps a number to a collection of proxies in an object property.
15
 *
16
 * @author Stratadox
17
 */
18
final class HasManyProxies
19
{
20
    public static function inProperty(
21
        string $name,
22
        Deserializer $collection,
23
        ProxyFactory $proxyFactory
24
    ): KeyedMapping {
25
        return Keyed::mapping(
26
            $name,
27
            NumberedProxyCollectionMapping::inProperty($name, $collection, $proxyFactory)
28
        );
29
    }
30
31
    public static function inPropertyWithDifferentKey(
32
        string $name,
33
        string $key,
34
        Deserializer $collection,
35
        ProxyFactory $proxyFactory
36
    ): KeyedMapping {
37
        return Keyed::mapping($key, DifferentKey::use(
38
            $key,
39
            NumberedProxyCollectionMapping::inProperty($name, $collection, $proxyFactory)
40
        ));
41
    }
42
}
43