Passed
Pull Request — master (#13)
by Gordon
01:41
created

SearchResults::getTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
3
/**
4
 * Created by PhpStorm.
5
 * User: gordon
6
 * Date: 24/3/2561
7
 * Time: 20:36 น.
8
 */
9
10
namespace Suilven\FreeTextSearch\Container;
11
12
use SilverStripe\ORM\ArrayList;
13
14
/**
15
 * Class SearchResults
16
 *
17
 * Store the search results in a manner that is renderable in a SilverStripe template
18
 *
19
 * @package Suilven\FreeTextSearch\Container
20
 */
21
class SearchResults
22
{
23
24
    /** @var array<string,int|bool|float|string> */
25
    private $facets;
26
27
    /** @var string */
28
    private $index;
29
30
    /** @var int */
31
    private $page;
32
33
    /** @var int */
34
    private $pageSize;
35
36
    /** @var string */
37
    private $query;
38
39
    /** @var \SilverStripe\ORM\ArrayList */
40
    private $records;
41
42
    /** @var float the time in seconds */
43
    private $time;
44
45
    public function __construct()
46
    {
47
        $this->time = 0;
48
    }
49
50
51
    /** @param array<string,int|bool|float|string> $newFacets */
52
    public function setFacets(array $newFacets): void
53
    {
54
        $this->facets = $newFacets;
55
    }
56
57
58
    public function setIndex(string $newIndex): void
59
    {
60
        $this->index = $newIndex;
61
    }
62
63
64
    public function getNumberOfResults(): int
65
    {
66
        return \count($this->records);
67
    }
68
69
70
    public function getPage(): int
71
    {
72
        return $this->page;
73
    }
74
75
76
    public function setPage(int $newPage): void
77
    {
78
        $this->page = $newPage;
79
    }
80
81
82
    public function getPageSize(): int
83
    {
84
        return $this->pageSize;
85
    }
86
87
88
    public function setPageSize(int $newPageSize): void
89
    {
90
        $this->pageSize = $newPageSize;
91
    }
92
93
94
    public function getQuery(): string
95
    {
96
        return $this->query;
97
    }
98
99
100
    public function setQuery(string $newQuery): void
101
    {
102
        $this->query = $newQuery;
103
    }
104
105
106
    public function setRecords(ArrayList $newRecords): void
107
    {
108
        $this->records = $newRecords;
109
    }
110
111
112
    public function getRecords(): \SilverStripe\ORM\ArrayList
113
    {
114
        return $this->records;
115
    }
116
117
118
    public function getTime(): float
119
    {
120
        return $this->time;
121
    }
122
123
124
    public function setTime(float $newTime): void
125
    {
126
        $this->time = $newTime;
127
    }
128
}
129