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

InterestOverTimeResult   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 57
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getInterestAt() 0 4 1
A getValues() 0 4 1
A getFirstValue() 0 4 1
A hasData() 0 4 1
A jsonSerialize() 0 9 1
1
<?php declare(strict_types=1);
2
3
namespace GSoares\GoogleTrends\Result;
4
5
use DateTimeInterface;
6
use JsonSerializable;
7
8
/**
9
 * @author Gabriel Felipe Soares <[email protected]>
10
 */
11
class InterestOverTimeResult implements JsonSerializable
12
{
13
    /**
14
     * @var DateTimeInterface
15
     */
16
    private $interestAt;
17
18
    /**
19
     * @var int[]
20
     */
21
    private $values;
22
23
    /**
24
     * @var bool
25
     */
26
    private $hasData;
27
28 3
    public function __construct(DateTimeInterface $at, array $values, bool $hasData)
29
    {
30 3
        $this->interestAt = $at;
31 3
        $this->values = $values;
32 3
        $this->hasData = $hasData;
33 3
    }
34
35 1
    public function getInterestAt(): DateTimeInterface
36
    {
37 1
        return $this->interestAt;
38
    }
39
40 1
    public function getValues(): array
41
    {
42 1
        return $this->values;
43
    }
44
45 1
    public function getFirstValue(): int
46
    {
47 1
        return $this->values[0] ?? 0;
48
    }
49
50 1
    public function hasData(): bool
51
    {
52 1
        return $this->hasData;
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58 1
    public function jsonSerialize(): array
59
    {
60
        return [
61 1
            'interestAt' => $this->getInterestAt()->format(DATE_ATOM),
62 1
            'values' => $this->getValues(),
63 1
            'firstValue' => $this->getFirstValue(),
64 1
            'hasData' => $this->hasData()
65
        ];
66
    }
67
}
68