NormalizationFieldMapping   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 60
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPolicy() 0 3 1
A getFieldNormalizer() 0 3 1
A __construct() 0 10 1
A getGroups() 0 3 1
A getName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Mapping;
6
7
use Chubbyphp\Serialization\Normalizer\FieldNormalizerInterface;
8
use Chubbyphp\Serialization\Policy\NullPolicy;
9
use Chubbyphp\Serialization\Policy\PolicyInterface;
10
11
final class NormalizationFieldMapping implements NormalizationFieldMappingInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $name;
17
18
    /**
19
     * @var array
20
     */
21
    private $groups;
22
23
    /**
24
     * @var FieldNormalizerInterface
25
     */
26
    private $fieldNormalizer;
27
28
    /**
29
     * @var PolicyInterface
30
     */
31
    private $policy;
32
33
    /**
34
     * @param string $name
35
     */
36
    public function __construct(
37
        $name,
38
        array $groups,
39 4
        FieldNormalizerInterface $fieldNormalizer,
40
        PolicyInterface $policy = null
41
    ) {
42
        $this->name = $name;
43
        $this->groups = $groups;
44
        $this->fieldNormalizer = $fieldNormalizer;
45 4
        $this->policy = $policy ?? new NullPolicy();
46 4
    }
47 4
48 4
    public function getName(): string
49 4
    {
50
        return $this->name;
51
    }
52
53
    /**
54 1
     * @deprecated
55
     *
56 1
     * @return string[]
57
     */
58
    public function getGroups(): array
59
    {
60
        return $this->groups;
61
    }
62
63
    public function getFieldNormalizer(): FieldNormalizerInterface
64 1
    {
65
        return $this->fieldNormalizer;
66 1
    }
67
68
    public function getPolicy(): PolicyInterface
69
    {
70
        return $this->policy;
71
    }
72
}
73