Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
AutocompleteCommand
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 getArguments
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getQuery
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDomain
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Get autocomplete results from the EDS 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
30namespace VuFindSearch\Backend\EDS\Command;
31
32use VuFindSearch\Backend\EDS\Backend;
33use VuFindSearch\Command\CallMethodCommand;
34use VuFindSearch\ParamBag;
35
36/**
37 * Get autocomplete results from the EDS backend
38 *
39 * @category VuFind
40 * @package  Search
41 * @author   Demian Katz <demian.katz@villanova.edu>
42 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
43 * @link     https://vufind.org
44 */
45class AutocompleteCommand extends CallMethodCommand
46{
47    /**
48     * Simple query string.
49     *
50     * @var string
51     */
52    protected $query;
53
54    /**
55     * Autocomplete type.
56     *
57     * @var string
58     */
59    protected $domain;
60
61    /**
62     * Constructor.
63     *
64     * @param string    $backendId Search backend identifier
65     * @param string    $query     Simple query string
66     * @param string    $domain    Autocomplete type, e.g. 'rawqueries' or 'holdings'
67     * @param ?ParamBag $params    Search backend parameters
68     */
69    public function __construct(
70        string $backendId,
71        string $query,
72        string $domain,
73        ParamBag $params = null
74    ) {
75        $this->query = $query;
76        $this->domain = $domain;
77        parent::__construct(
78            $backendId,
79            Backend::class,
80            'autocomplete',
81            $params
82        );
83    }
84
85    /**
86     * Return search backend interface method arguments.
87     *
88     * @return array
89     */
90    public function getArguments(): array
91    {
92        return [
93            $this->getQuery(),
94            $this->getDomain(),
95        ];
96    }
97
98    /**
99     * Return simple query string.
100     *
101     * @return string
102     */
103    public function getQuery(): string
104    {
105        return $this->query;
106    }
107
108    /**
109     * Return autocomplete type.
110     *
111     * @return string
112     */
113    public function getDomain(): string
114    {
115        return $this->domain;
116    }
117}