RegionNameEntity::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
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