Passed
Pull Request — master (#26)
by
unknown
01:39
created

InterestByCityResult   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 13.25 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 11
loc 83
ccs 0
cts 50
cp 0
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A getGeoName() 0 4 1
A getValue() 0 4 1
A getMaxValueIndex() 0 4 1
A hasData() 0 4 1
A getLat() 0 4 1
A getLng() 0 4 1
A jsonSerialize() 11 11 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 declare(strict_types=1);
2
3
namespace GSoares\GoogleTrends\Result;
4
5
use JsonSerializable;
6
7
/**
8
 * @author Gabriel Felipe Soares <[email protected]>
9
 */
10
class InterestByCityResult implements JsonSerializable
11
{
12
    /**
13
     * @var string
14
     */
15
    private $geoName;
16
17
    /**
18
     * @var int
19
     */
20
    private $value;
21
22
    /**
23
     * @var int
24
     */
25
    private $maxValueIndex;
26
27
    /**
28
     * @var bool
29
     */
30
    private $hasData;
31
32
    public function __construct(
33
        string $geoName,
34
        int $value,
35
        int $maxValueIndex,
36
        bool $hasData,
37
        string $lat,
38
        string $lng
39
    ) {
40
        $this->geoName = $geoName;
41
        $this->value = $value;
42
        $this->maxValueIndex = $maxValueIndex;
43
        $this->hasData = $hasData;
44
        $this->lat = $lat;
45
        $this->lng = $lng;
46
    }
47
48
    public function getGeoName(): string
49
    {
50
        return $this->geoName;
51
    }
52
53
    public function getValue(): int
54
    {
55
        return $this->value;
56
    }
57
58
    public function getMaxValueIndex(): int
59
    {
60
        return $this->maxValueIndex;
61
    }
62
63
    public function hasData(): bool
64
    {
65
        return $this->hasData;
66
    }
67
    
68
    public function getLat(): string
69
    {
70
        return $this->lat;
71
    }
72
    
73
    public function getLng(): string
74
    {
75
        return $this->lng;
76
    }
77
78
    /**
79
     * @inheritDoc
80
     */
81 View Code Duplication
    public function jsonSerialize(): array
0 ignored issues
show
Duplication introduced by
This method 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...
82
    {
83
        return [
84
            'geoName' => $this->getGeoName(),
85
            'value' => $this->getValue(),
86
            'maxValueIndex' => $this->getMaxValueIndex(),
87
            'hasData' => $this->hasData(),
88
            'lat' => $this->getLat(),
89
            'lng' => $this->getLng()
90
        ];
91
    }
92
}
93