AbstractResultCollection   A
last analyzed

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