Passed
Push — master ( df2e7d...4ffc8b )
by Gabriel Felipe
01:40 queued 10s
created

InterestOverTimeCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A getSearchUrl() 4 4 1
A getResults() 4 4 1
A getTotalResults() 4 4 1
A jsonSerialize() 8 8 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 View Code Duplication
class InterestOverTimeCollection 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...
11
{
12
    /**
13
     * @var string
14
     */
15
    private $searchUrl;
16
17
    /**
18
     * @var InterestOverTimeResult[]
19
     */
20
    private $results;
21
22
    /**
23
     * @var int
24
     */
25
    private $totalResults;
26
27 3
    public function __construct(string $searchUrl, InterestOverTimeResult ...$terms)
28
    {
29 3
        $this->searchUrl = $searchUrl;
30 3
        $this->results = $terms;
31 3
        $this->totalResults = count($terms);
32 3
    }
33
34 2
    public function getSearchUrl(): string
35
    {
36 2
        return $this->searchUrl;
37
    }
38
39
    /**
40
     * @return InterestOverTimeResult[]
41
     */
42 2
    public function getResults(): array
43
    {
44 2
        return $this->results;
45
    }
46
47 2
    public function getTotalResults(): int
48
    {
49 2
        return $this->totalResults;
50
    }
51
52
    /**
53
     * @inheritDoc
54
     */
55 1
    public function jsonSerialize(): array
56
    {
57
        return [
58 1
            'searchUrl' => $this->getSearchUrl(),
59 1
            'totalResults' => $this->getTotalResults(),
60 1
            'results' => $this->getResults(),
61
        ];
62
    }
63
}
64