Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
GetLuceneHelperCommand | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
6 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
5 |
1 | <?php |
2 | |
3 | /** |
4 | * Command to fetch a Lucene helper object from a search backend. |
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\BackendInterface; |
33 | use VuFindSearch\Backend\Solr\LuceneSyntaxHelper; |
34 | |
35 | use function is_callable; |
36 | |
37 | /** |
38 | * Command to fetch a Lucene helper object from a search backend. |
39 | * |
40 | * @category VuFind |
41 | * @package Search |
42 | * @author Demian Katz <demian.katz@villanova.edu> |
43 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
44 | * @link https://vufind.org |
45 | */ |
46 | class GetLuceneHelperCommand extends \VuFindSearch\Command\AbstractBase |
47 | { |
48 | /** |
49 | * Constructor. |
50 | * |
51 | * @param string $backendId Search backend identifier |
52 | */ |
53 | public function __construct(string $backendId) |
54 | { |
55 | parent::__construct($backendId, []); |
56 | } |
57 | |
58 | /** |
59 | * Execute command on backend. |
60 | * |
61 | * @param BackendInterface $backend Backend |
62 | * |
63 | * @return CommandInterface Command instance for method chaining |
64 | */ |
65 | public function execute(BackendInterface $backend): CommandInterface |
66 | { |
67 | $this->validateBackend($backend); |
68 | $qb = is_callable([$backend, 'getQueryBuilder']) |
69 | ? $backend->getQueryBuilder() : false; |
70 | $result = $qb && is_callable([$qb, 'getLuceneHelper']) |
71 | ? $qb->getLuceneHelper() : false; |
72 | return $this->finalizeExecution( |
73 | $result instanceof LuceneSyntaxHelper ? $result : false |
74 | ); |
75 | } |
76 | } |