Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
SimilarCommand
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
7 / 7
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
1<?php
2
3/**
4 * Return similar 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   David Maus <maus@hab.de>
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
32namespace VuFindSearch\Command;
33
34use VuFindSearch\Command\Feature\RecordIdentifierTrait;
35use VuFindSearch\Feature\SimilarInterface;
36use VuFindSearch\ParamBag;
37
38/**
39 * Return similar records command.
40 *
41 * @category VuFind
42 * @package  Search
43 * @author   David Maus <maus@hab.de>
44 * @author   Aleksi Peebles <aleksi.peebles@helsinki.fi>
45 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
46 * @link     https://vufind.org
47 */
48class SimilarCommand extends CallMethodCommand
49{
50    use RecordIdentifierTrait;
51
52    /**
53     * SimilarCommand constructor.
54     *
55     * @param string    $backendId Search backend identifier
56     * @param string    $id        Identifier of record to compare with
57     * @param ?ParamBag $params    Search backend parameters
58     */
59    public function __construct(
60        string $backendId,
61        string $id,
62        ?ParamBag $params = null
63    ) {
64        $this->id = $id;
65        parent::__construct(
66            $backendId,
67            SimilarInterface::class,
68            'similar',
69            $params
70        );
71    }
72
73    /**
74     * Return search backend interface method arguments.
75     *
76     * @return array
77     */
78    public function getArguments(): array
79    {
80        return [
81            $this->getRecordIdentifier(),
82            $this->getSearchParameters(),
83        ];
84    }
85}