Completed
Push — master ( 4ffc8b...8e0049 )
by Gabriel Felipe
02:04 queued 10s
created

AbstractResultCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

5 Methods

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