RegionNameEntity   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 94.37 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 67
loc 71
ccs 6
cts 15
cp 0.4
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 7 7 1
A getLanguage() 4 4 1
A setLanguage() 6 6 1
A getName() 4 4 1
A setName() 6 6 1
A __toString() 1 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
namespace GeoBase\Regions\Region\RegionName;
4
5
use GeoBase\Countries\Language\LanguageEntity;
6
use JsonSerializable;
7
8 View Code Duplication
class RegionNameEntity implements JsonSerializable
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...
9
{
10
    /**
11
     * @var string
12
     */
13
    private $name;
14
15
    /**
16
     * @var string|LanguageEntity
17
     */
18
    private $language;
19
20
    /**
21
     * @return array
22
     */
23
    public function jsonSerialize()
24
    {
25
        return [
26
            'name'     => $this->getName(),
27
            'language' => $this->getLanguage(),
28
        ];
29
    }
30
31
    /**
32
     * @return LanguageEntity
33
     */
34
    public function getLanguage()
35
    {
36
        return $this->language;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->language; of type string|GeoBase\Countries\Language\LanguageEntity adds the type string to the return on line 36 which is incompatible with the return type documented by GeoBase\Regions\Region\R...NameEntity::getLanguage of type GeoBase\Countries\Language\LanguageEntity.
Loading history...
37
    }
38
39
    /**
40
     * @param LanguageEntity|string $language
41
     *
42
     * @return $this
43
     */
44 4
    public function setLanguage($language)
45
    {
46 4
        $this->language = $language;
47
48 4
        return $this;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getName()
55
    {
56
        return $this->name;
57
    }
58
59
    /**
60
     * @param string $name
61
     *
62
     * @return $this
63
     */
64 4
    public function setName($name)
65
    {
66 4
        $this->name = $name;
67
68 4
        return $this;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function __toString()
75
    {
76
        return $this->getName();
77
    }
78
}
79