Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
78.57% |
11 / 14 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
Buchhandel | |
78.57% |
11 / 14 |
|
50.00% |
1 / 2 |
7.48 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
getUrl | |
70.00% |
7 / 10 |
|
0.00% |
0 / 1 |
6.97 |
1 | <?php |
2 | |
3 | /** |
4 | * Buchhandel cover content loader. |
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 | * @author Jochen Lienhard <lienhard@ub.uni-freiburg.de> |
27 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
28 | * @link https://vufind.org/wiki/development Wiki |
29 | */ |
30 | |
31 | namespace VuFind\Content\Covers; |
32 | |
33 | /** |
34 | * Buchhandel cover content loader. |
35 | * |
36 | * @category VuFind |
37 | * @package Content |
38 | * @author Demian Katz <demian.katz@villanova.edu> |
39 | * @author Jochen Lienhard <lienhard@ub.uni-freiburg.de> |
40 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
41 | * @link https://vufind.org/wiki/development Wiki |
42 | */ |
43 | class Buchhandel extends \VuFind\Content\AbstractCover |
44 | { |
45 | /** |
46 | * Base URL for Buchhandel |
47 | * |
48 | * @var string |
49 | */ |
50 | protected $url; |
51 | |
52 | /** |
53 | * API token for Buchhandel |
54 | * |
55 | * @var string |
56 | */ |
57 | protected $apiToken; |
58 | |
59 | /** |
60 | * Constructor |
61 | * |
62 | * @param string $url Base URL for Buchhandel |
63 | * @param string $apiToken API token for Buchhandel |
64 | */ |
65 | public function __construct($url, $apiToken) |
66 | { |
67 | $this->url = $url; |
68 | $this->apiToken = $apiToken; |
69 | $this->supportsIsbn = true; |
70 | $this->cacheAllowed = false; |
71 | } |
72 | |
73 | /** |
74 | * Get image URL for a particular API token and set of IDs (or false if invalid). |
75 | * |
76 | * @param string $key API key |
77 | * @param string $size Size of image to load (small/medium/large) |
78 | * @param array $ids Associative array of identifiers (keys may include 'isbn' |
79 | * pointing to an ISBN object and 'issn' pointing to a string) |
80 | * |
81 | * @return string|bool |
82 | * |
83 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
84 | */ |
85 | public function getUrl($key, $size, $ids) |
86 | { |
87 | if (!isset($ids['isbn'])) { |
88 | return false; |
89 | } |
90 | $isbn = $ids['isbn']->get13(); |
91 | switch ($size) { |
92 | case 'small': |
93 | case 'medium': |
94 | case 'large': |
95 | $lsize = substr($size, 0, 1); |
96 | break; |
97 | default: |
98 | $lsize = 's'; |
99 | break; |
100 | } |
101 | |
102 | return "{$this->url}{$isbn}/{$lsize}?access_token={$this->apiToken}"; |
103 | } |
104 | } |