Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Explanation
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 performRequest
n/a
0 / 0
n/a
0 / 0
0
 getLookfor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRecordId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getParams
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Abstract explanation model.
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Hebis Verbundzentrale 2023.
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_Base
25 * @author   Dennis Schrittenlocher <Dennis.Schrittenlocher@outlook.de>
26 * @author   Thomas Wagener <wagener@hebis.uni-frankfurt.de>
27 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
28 * @link     https://vufind.org Main Page
29 */
30
31namespace VuFind\Search\Base;
32
33use Laminas\Log\LoggerAwareInterface;
34use VuFind\Log\LoggerAwareTrait;
35use VuFindSearch\Service as SearchService;
36
37/**
38 * Abstract explanation model.
39 *
40 * This abstract class defines the methods for modeling an explanation in VuFind.
41 *
42 * @category VuFind
43 * @package  Search_Base
44 * @author   Dennis Schrittenlocher <Dennis.Schrittenlocher@outlook.de>
45 * @author   Thomas Wagener <wagener@hebis.uni-frankfurt.de>
46 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
47 * @link     https://vufind.org Main Page
48 */
49abstract class Explanation implements LoggerAwareInterface
50{
51    use LoggerAwareTrait;
52
53    /**
54     * Configuration
55     *
56     * @var \Laminas\Config\Config
57     */
58    protected $config;
59
60    /**
61     * Configuration file to read search settings from
62     *
63     * @var string
64     */
65    protected $searchIni = 'searches';
66
67    /**
68     * Search Service
69     *
70     * @var SearchService
71     */
72    protected $searchService;
73
74    /**
75     * Search string used for query.
76     *
77     * @var string
78     */
79    protected $lookfor;
80
81    /**
82     * RecordId of title the explanation is built for.
83     *
84     * @var string
85     */
86    protected $recordId;
87
88    /**
89     * Search parameters object
90     *
91     * @var \VuFind\Search\Base\Params
92     */
93    protected $params;
94
95    /**
96     * Constructor
97     *
98     * @param \VuFind\Search\Base\Params   $params        Search Parameter
99     * @param SearchService                $searchService Search Service
100     * @param \VuFind\Config\PluginManager $configLoader  Config Loader
101     */
102    public function __construct($params, $searchService, $configLoader)
103    {
104        $this->params = $params;
105        $this->searchService = $searchService;
106        $this->config = $configLoader->get($this->searchIni);
107    }
108
109    /**
110     * Performing request and creating explanation.
111     *
112     * @param string $recordId Record Id
113     *
114     * @throws \VuFindSearch\Backend\Exception\BackendException
115     * @return void
116     */
117    abstract public function performRequest($recordId);
118
119    /**
120     * Get the search string used for query.
121     *
122     * @return string
123     */
124    public function getLookfor()
125    {
126        return $this->lookfor;
127    }
128
129    /**
130     * Get the record id of title the explanation is built for.
131     *
132     * @return string
133     */
134    public function getRecordId()
135    {
136        return $this->recordId;
137    }
138
139    /**
140     * Get the search parameters object.
141     *
142     * @return \VuFind\Search\Base\Params
143     */
144    public function getParams()
145    {
146        return $this->params;
147    }
148}