Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
AbstractBase | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
getIsbn10 | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
20 | |||
getHttpClient | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
loadByIsbn | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | |
3 | /** |
4 | * Abstract base for content loader plug-ins. |
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 Content |
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 Wiki |
28 | */ |
29 | |
30 | namespace VuFind\Content; |
31 | |
32 | use VuFindCode\ISBN; |
33 | |
34 | use function is_object; |
35 | |
36 | /** |
37 | * Abstract base for content loader plug-ins. |
38 | * |
39 | * @category VuFind |
40 | * @package Content |
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 Wiki |
44 | */ |
45 | abstract class AbstractBase implements |
46 | \VuFindHttp\HttpServiceAwareInterface, |
47 | \Laminas\Log\LoggerAwareInterface |
48 | { |
49 | use \VuFind\Log\LoggerAwareTrait; |
50 | use \VuFindHttp\HttpServiceAwareTrait; |
51 | |
52 | /** |
53 | * Attempt to get an ISBN-10; revert to ISBN-13 only when ISBN-10 representation |
54 | * is impossible. |
55 | * |
56 | * @param ISBN $isbnObj ISBN object to convert |
57 | * |
58 | * @return string |
59 | */ |
60 | protected function getIsbn10($isbnObj) |
61 | { |
62 | $isbn = is_object($isbnObj) ? $isbnObj->get10() : false; |
63 | return (!$isbn && is_object($isbnObj)) ? $isbnObj->get13() : $isbn; |
64 | } |
65 | |
66 | /** |
67 | * Get an HTTP client |
68 | * |
69 | * @param string $url URL for client to use |
70 | * |
71 | * @return \Laminas\Http\Client |
72 | * @throws \Exception |
73 | */ |
74 | protected function getHttpClient($url = null) |
75 | { |
76 | if (null === $this->httpService) { |
77 | throw new \Exception('HTTP service missing.'); |
78 | } |
79 | return $this->httpService->createClient($url); |
80 | } |
81 | |
82 | /** |
83 | * Load results for a particular API key and ISBN. |
84 | * |
85 | * @param string $key API key |
86 | * @param ISBN $isbnObj ISBN object |
87 | * |
88 | * @return array|string For array of strings returned, they all are escaped in the template and presented as list. |
89 | * If string is returned it is considered as raw HTML and is NOT escaped. |
90 | */ |
91 | abstract public function loadByIsbn($key, ISBN $isbnObj); |
92 | } |