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

Keyed::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
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