Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
18 / 18 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
TermsCommand | |
100.00% |
18 / 18 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
getArguments | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
getField | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getStart | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getLimit | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * Fetch terms from the backend (currently only supported by Solr) |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2021. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package Search |
25 | * @author Demian Katz <demian.katz@villanova.edu> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org |
28 | */ |
29 | |
30 | namespace VuFindSearch\Command; |
31 | |
32 | use VuFindSearch\Backend\Solr\Backend; |
33 | use VuFindSearch\ParamBag; |
34 | |
35 | /** |
36 | * Fetch terms from the backend (currently only supported by Solr) |
37 | * |
38 | * @category VuFind |
39 | * @package Search |
40 | * @author Demian Katz <demian.katz@villanova.edu> |
41 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
42 | * @link https://vufind.org |
43 | */ |
44 | class TermsCommand extends CallMethodCommand |
45 | { |
46 | /** |
47 | * Index field. |
48 | * |
49 | * @var string |
50 | */ |
51 | protected $field; |
52 | |
53 | /** |
54 | * Starting term. |
55 | * |
56 | * @var string |
57 | */ |
58 | protected $start; |
59 | |
60 | /** |
61 | * Maximum number of terms. |
62 | * |
63 | * @var int |
64 | */ |
65 | protected $limit; |
66 | |
67 | /** |
68 | * Constructor. |
69 | * |
70 | * @param string $backendId Search backend identifier |
71 | * @param string $field Index field |
72 | * @param string $start Starting term (blank for beginning of list) |
73 | * @param int $limit Maximum number of terms |
74 | * @param ?ParamBag $params Search backend parameters |
75 | */ |
76 | public function __construct( |
77 | string $backendId, |
78 | string $field, |
79 | string $start, |
80 | int $limit, |
81 | ParamBag $params = null |
82 | ) { |
83 | $this->field = $field; |
84 | $this->start = $start; |
85 | $this->limit = $limit; |
86 | parent::__construct( |
87 | $backendId, |
88 | Backend::class, // we should define interface, if needed in more places |
89 | 'terms', |
90 | $params |
91 | ); |
92 | } |
93 | |
94 | /** |
95 | * Return search backend interface method arguments. |
96 | * |
97 | * @return array |
98 | */ |
99 | public function getArguments(): array |
100 | { |
101 | return [ |
102 | $this->getField(), |
103 | $this->getStart(), |
104 | $this->getLimit(), |
105 | $this->getSearchParameters(), |
106 | ]; |
107 | } |
108 | |
109 | /** |
110 | * Return index field. |
111 | * |
112 | * @return string |
113 | */ |
114 | public function getField(): string |
115 | { |
116 | return $this->field; |
117 | } |
118 | |
119 | /** |
120 | * Return starting term. |
121 | * |
122 | * @return string |
123 | */ |
124 | public function getStart(): string |
125 | { |
126 | return $this->start; |
127 | } |
128 | |
129 | /** |
130 | * Return maximum number of terms. |
131 | * |
132 | * @return int |
133 | */ |
134 | public function getLimit(): int |
135 | { |
136 | return $this->limit; |
137 | } |
138 | } |