Passed
Pull Request — master (#15)
by
unknown
03:56
created

NormalizationFieldMapping::getPolicy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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\PolicyInterface;
9
use Chubbyphp\Serialization\Policy\NullPolicy;
10
11 View Code Duplication
final class NormalizationFieldMapping implements NormalizationFieldMappingInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
     * @param array                    $groups
36
     * @param FieldNormalizerInterface $fieldNormalizer
37
     * @param PolicyInterface|null     $policy
38
     */
39 4
    public function __construct(
40
        $name,
41
        array $groups,
42
        FieldNormalizerInterface $fieldNormalizer,
43
        PolicyInterface $policy = null
44
    ) {
45 4
        $this->name = $name;
46 4
        $this->groups = $groups;
47 4
        $this->fieldNormalizer = $fieldNormalizer;
48 4
        $this->policy = $policy ?? new NullPolicy();
49 4
    }
50
51
    /**
52
     * @return string
53
     */
54 1
    public function getName(): string
55
    {
56 1
        return $this->name;
57
    }
58
59
    /**
60
     * @deprecated
61
     *
62
     * @return string[]
63
     */
64 1
    public function getGroups(): array
65
    {
66 1
        return $this->groups;
67
    }
68
69
    /**
70
     * @return FieldNormalizerInterface
71
     */
72 1
    public function getFieldNormalizer(): FieldNormalizerInterface
73
    {
74 1
        return $this->fieldNormalizer;
75
    }
76
77
    /**
78
     * @return PolicyInterface
79
     */
80 1
    public function getPolicy(): PolicyInterface
81
    {
82 1
        return $this->policy;
83
    }
84
}
85