Test Setup Failed
Push — master ( b50703...9d91c5 )
by Dominik
06:16
created

DenormalizingFieldMapping::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization\Mapping;
6
7
use Chubbyphp\Deserialization\Accessor\PropertyAccessor;
8
use Chubbyphp\Deserialization\Denormalizer\FieldDenormalizer;
9
use Chubbyphp\Deserialization\Denormalizer\FieldDenormalizerInterface;
10
11
final class DenormalizingFieldMapping implements DenormalizingFieldMappingInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $name;
17
18
    /**
19
     * @var FieldDenormalizerInterface
20
     */
21
    private $fieldDenormalizer;
22
23
    /**
24
     * @param string                          $name
25
     * @param FieldDenormalizerInterface|null $fieldDenormalizer
26
     */
27
    public function __construct($name, FieldDenormalizerInterface $fieldDenormalizer = null)
28
    {
29
        $this->name = $name;
30
        $this->fieldDenormalizer = $fieldDenormalizer ?? new FieldDenormalizer(new PropertyAccessor($name));
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getName(): string
37
    {
38
        return $this->name;
39
    }
40
41
    /**
42
     * @return FieldDenormalizerInterface
43
     */
44
    public function getFieldDenormalizer(): FieldDenormalizerInterface
45
    {
46
        return $this->fieldDenormalizer;
47
    }
48
}
49