Passed
Pull Request — master (#15)
by
unknown
02:36
created

NormalizationLinkMapping   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 74
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 74
loc 74
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A getName() 4 4 1
A getGroups() 4 4 1
A getLinkNormalizer() 4 4 1
A getPolicy() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Mapping;
6
7
use Chubbyphp\Serialization\Normalizer\LinkNormalizerInterface;
8
use Chubbyphp\Serialization\Policy\PolicyInterface;
9
use Chubbyphp\Serialization\Policy\NullPolicy;
10
11 View Code Duplication
final class NormalizationLinkMapping implements NormalizationLinkMappingInterface
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 LinkNormalizerInterface
25
     */
26
    private $linkNormalizer;
27
28
    /**
29
     * @var PolicyInterface
30
     */
31
    private $policy;
32
33
    /**
34
     * @param string                  $name
35
     * @param array                   $groups
36
     * @param LinkNormalizerInterface $linkNormalizer
37
     * @param PolicyInterface|null    $policy
38
     */
39 4
    public function __construct(
40
        string $name,
41
        array $groups,
42
        LinkNormalizerInterface $linkNormalizer,
43
        PolicyInterface $policy = null
44
    ) {
45 4
        $this->name = $name;
46 4
        $this->groups = $groups;
47 4
        $this->linkNormalizer = $linkNormalizer;
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 LinkNormalizerInterface
71
     */
72 1
    public function getLinkNormalizer(): LinkNormalizerInterface
73
    {
74 1
        return $this->linkNormalizer;
75
    }
76
77
    /**
78
     * @return PolicyInterface
79
     */
80 1
    public function getPolicy(): PolicyInterface
81
    {
82 1
        return $this->policy;
83
    }
84
}
85