Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
20 / 20 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
GetIdsCommand | |
100.00% |
20 / 20 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
getArguments | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Get identifiers of records command. |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
9 | * Copyright (C) The National Library of Finland 2021. |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License version 2, |
13 | * as published by the Free Software Foundation. |
14 | * |
15 | * This program is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | * GNU General Public License for more details. |
19 | * |
20 | * You should have received a copy of the GNU General Public License |
21 | * along with this program; if not, write to the Free Software |
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 | * |
24 | * @category VuFind |
25 | * @package Search |
26 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
27 | * @author Aleksi Peebles <aleksi.peebles@helsinki.fi> |
28 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
29 | * @link https://vufind.org |
30 | */ |
31 | |
32 | namespace VuFindSearch\Command; |
33 | |
34 | use VuFindSearch\Backend\BackendInterface; |
35 | use VuFindSearch\Command\Feature\QueryOffsetLimitTrait; |
36 | use VuFindSearch\Feature\GetIdsInterface; |
37 | use VuFindSearch\ParamBag; |
38 | use VuFindSearch\Query\QueryInterface; |
39 | |
40 | /** |
41 | * Get identifiers of records command. |
42 | * |
43 | * @category VuFind |
44 | * @package Search |
45 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
46 | * @author Aleksi Peebles <aleksi.peebles@helsinki.fi> |
47 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
48 | * @link https://vufind.org |
49 | */ |
50 | class GetIdsCommand extends CallMethodCommand |
51 | { |
52 | use QueryOffsetLimitTrait; |
53 | |
54 | /** |
55 | * GetIdsCommand constructor. |
56 | * |
57 | * @param string $backendId Search backend identifier |
58 | * @param QueryInterface $query Search query |
59 | * @param int $offset Search offset |
60 | * @param int $limit Search limit |
61 | * @param ?ParamBag $params Search backend parameters |
62 | */ |
63 | public function __construct( |
64 | string $backendId, |
65 | QueryInterface $query, |
66 | int $offset = 0, |
67 | int $limit = 20, |
68 | ?ParamBag $params = null |
69 | ) { |
70 | $this->query = $query; |
71 | $this->offset = $offset; |
72 | $this->limit = $limit; |
73 | parent::__construct( |
74 | $backendId, |
75 | GetIdsInterface::class, |
76 | 'getIds', |
77 | $params, |
78 | 'getids' |
79 | ); |
80 | } |
81 | |
82 | /** |
83 | * Return search backend interface method arguments. |
84 | * |
85 | * @return array |
86 | */ |
87 | public function getArguments(): array |
88 | { |
89 | return [ |
90 | $this->getQuery(), |
91 | $this->getOffset(), |
92 | $this->getLimit(), |
93 | $this->getSearchParameters(), |
94 | ]; |
95 | } |
96 | |
97 | /** |
98 | * Execute command on backend. |
99 | * |
100 | * @param BackendInterface $backend Backend |
101 | * |
102 | * @return CommandInterface Command instance for method chaining |
103 | */ |
104 | public function execute(BackendInterface $backend): CommandInterface |
105 | { |
106 | if (!($backend instanceof GetIdsInterface)) { |
107 | $this->interface = BackendInterface::class; |
108 | $this->method = 'search'; |
109 | } |
110 | return parent::execute($backend); |
111 | } |
112 | } |