Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
WorldCat | |
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
3.14 | |
0.00% |
0 / 1 |
setRawData | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
getOCLC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Model for MARC records in WorldCat. |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
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 RecordDrivers |
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/wiki/development:plugins:record_drivers Wiki |
28 | */ |
29 | |
30 | namespace VuFind\RecordDriver; |
31 | |
32 | use VuFind\RecordDriver\Feature\MarcAdvancedTrait; |
33 | use VuFind\RecordDriver\Feature\MarcBasicTrait; |
34 | use VuFind\RecordDriver\Feature\MarcReaderTrait; |
35 | |
36 | /** |
37 | * Model for MARC records in WorldCat. |
38 | * |
39 | * @category VuFind |
40 | * @package RecordDrivers |
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/wiki/development:plugins:record_drivers Wiki |
44 | */ |
45 | class WorldCat extends DefaultRecord |
46 | { |
47 | use MarcReaderTrait, MarcAdvancedTrait, MarcBasicTrait { |
48 | MarcBasicTrait::getNewerTitles insteadof MarcAdvancedTrait; |
49 | MarcBasicTrait::getPreviousTitles insteadof MarcAdvancedTrait; |
50 | } |
51 | |
52 | /** |
53 | * Set raw data to initialize the object. |
54 | * |
55 | * @param mixed $data Raw data representing the record; Record Model |
56 | * objects are normally constructed by Record Driver objects using data |
57 | * passed in from a Search Results object. In this case, $data is a MARCXML |
58 | * document. |
59 | * |
60 | * @return void |
61 | */ |
62 | public function setRawData($data) |
63 | { |
64 | // Ensure that $driver->setRawData($driver->getRawData()) doesn't blow up: |
65 | if (isset($data['fullrecord'])) { |
66 | $data = $data['fullrecord']; |
67 | } |
68 | |
69 | // Map the WorldCat response into a format that the parent Solr-based |
70 | // record driver can understand. |
71 | parent::setRawData(['fullrecord' => $data]); |
72 | } |
73 | |
74 | /** |
75 | * Get the OCLC number of the record. |
76 | * |
77 | * @return array |
78 | */ |
79 | public function getOCLC() |
80 | { |
81 | return [$this->getUniqueID()]; |
82 | } |
83 | } |