Completed
Pull Request — master (#16)
by Gordon
02:18
created

SearchResults::setSuggestions()   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 1
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
    private $suggestions;
43
44
    /** @var float the time in seconds */
45
    private $time;
46
47
    public function __construct()
48
    {
49
        $this->time = 0;
50
        $this->suggestions =[];
51
    }
52
53
54
    /** @param array<string,int|bool|float|string> $newFacets */
55
    public function setFacets(array $newFacets): void
56
    {
57
        $this->facets = $newFacets;
58
    }
59
60
61
    public function setIndex(string $newIndex): void
62
    {
63
        $this->index = $newIndex;
64
    }
65
66
67
    public function getNumberOfResults(): int
68
    {
69
        return \count($this->records);
70
    }
71
72
73
    public function getPage(): int
74
    {
75
        return $this->page;
76
    }
77
78
79
    public function setPage(int $newPage): void
80
    {
81
        $this->page = $newPage;
82
    }
83
84
85
    public function getPageSize(): int
86
    {
87
        return $this->pageSize;
88
    }
89
90
91
    public function setPageSize(int $newPageSize): void
92
    {
93
        $this->pageSize = $newPageSize;
94
    }
95
96
97
    public function getQuery(): string
98
    {
99
        return $this->query;
100
    }
101
102
103
    public function setQuery(string $newQuery): void
104
    {
105
        $this->query = $newQuery;
106
    }
107
108
109
    public function setRecords(ArrayList $newRecords): void
110
    {
111
        $this->records = $newRecords;
112
    }
113
114
115
    public function getRecords(): \SilverStripe\ORM\ArrayList
116
    {
117
        return $this->records;
118
    }
119
120
    public function getSuggestions()
121
    {
122
        return $this->suggestions;
123
    }
124
125
126
    public function setSuggestions($newSuggestions)
127
    {
128
        $this->suggestions = $newSuggestions;
129
    }
130
131
132
    public function getTime(): float
133
    {
134
        return $this->time;
135
    }
136
137
138
    public function setTime(float $newTime): void
139
    {
140
        $this->time = $newTime;
141
    }
142
}
143