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

Keyed   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A key() 0 3 1
A name() 0 3 1
A value() 0 3 1
A mapping() 0 3 1
A __construct() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Hydration\Mapping\Property;
4
5
use Stratadox\HydrationMapping\KeyedMapping;
6
use Stratadox\HydrationMapping\Mapping;
7
8
/**
9
 * Adapter to make a regular mapping a KeyedMapping
10
 * @deprecated
11
 */
12
final class Keyed implements KeyedMapping
13
{
14
    /** @var string */
15
    private $key;
16
    /** @var Mapping */
17
    private $mapping;
18
19
    public function __construct(string $key, Mapping $mapping)
20
    {
21
        $this->key = $key;
22
        $this->mapping = $mapping;
23
    }
24
25
    public static function mapping(string $key, Mapping $mapping): KeyedMapping
26
    {
27
        return new self($key, $mapping);
28
    }
29
30
    public function key(): string
31
    {
32
        return $this->key;
33
    }
34
35
    public function name(): string
36
    {
37
        return $this->mapping->name();
38
    }
39
40
    public function value(array $data, $owner = null)
41
    {
42
        return $this->mapping->value($data, $owner);
43
    }
44
}
45