Passed
Push — master ( e44a5e...8f8314 )
by Gabriel Felipe
02:37 queued 11s
created

RelatedResult::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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 RelatedResult implements JsonSerializable
11
{
12
    /**
13
     * @var string
14
     */
15
    private $term;
16
17
    /**
18
     * @var bool
19
     */
20
    private $hasData;
21
22
    /**
23
     * @var int
24
     */
25
    private $value;
26
27
    /**
28
     * @var string
29
     */
30
    private $searchUrl;
31
32
    /**
33
     * @var string
34
     */
35
    private $metricType;
36
37 6
    public function __construct(string $term, bool $hasData, int $value, string $searchUrl, string $metricType = null)
38
    {
39 6
        $this->term = $term;
40 6
        $this->hasData = $hasData;
41 6
        $this->value = $value;
42 6
        $this->searchUrl = $searchUrl;
43 6
        $this->metricType = $metricType ?? 'TOP';
44 6
    }
45
46 1
    public function getTerm(): string
47
    {
48 1
        return $this->term;
49
    }
50
51 1
    public function hasData(): bool
52
    {
53 1
        return $this->hasData;
54
    }
55
56
    /**
57
     * @return int
58
     *
59
     * @deprecated         Use $this::getValue()
60
     * @codeCoverageIgnore
61
     */
62
    public function getRanking(): int
63
    {
64
        return $this->getValue();
65
    }
66
67 1
    public function getValue(): int
68
    {
69 1
        return $this->value;
70
    }
71
72 1
    public function getSearchUrl(): string
73
    {
74 1
        return $this->searchUrl;
75
    }
76
77 1
    public function getMetricType(): string
78
    {
79 1
        return $this->metricType;
80
    }
81
82 1
    public function jsonSerialize(): array
83
    {
84
        return [
85 1
            'term' => $this->getTerm(),
86 1
            'hasData' => $this->hasData(),
87 1
            'ranking' => $this->getValue(),
88 1
            'value' => $this->getValue(),
89 1
            'searchUrl' => $this->getSearchUrl(),
90 1
            'metricType' => $this->getMetricType(),
91
        ];
92
    }
93
}
94