Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
BrowZine
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getUrl
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3/**
4 * BrowZine cover content loader.
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2018.
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
30namespace VuFind\Content\Covers;
31
32use VuFindSearch\Backend\BrowZine\Command\LookupIssnsCommand;
33use VuFindSearch\Service;
34
35/**
36 * BrowZine cover content loader.
37 *
38 * @category VuFind
39 * @package  Content
40 * @author   Demian Katz <demian.katz@villanova.edu>
41 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
42 * @link     https://vufind.org/wiki/development Wiki
43 */
44class BrowZine extends \VuFind\Content\AbstractCover
45{
46    /**
47     * Search service
48     *
49     * @var Service
50     */
51    protected $searchService;
52
53    /**
54     * Constructor
55     *
56     * @param Service $searchService Search service
57     */
58    public function __construct(Service $searchService)
59    {
60        $this->searchService = $searchService;
61        $this->supportsIssn = true;
62    }
63
64    /**
65     * Get image URL for a particular API key and set of IDs (or false if invalid).
66     *
67     * @param string $key  API key
68     * @param string $size Size of image to load (small/medium/large)
69     * @param array  $ids  Associative array of identifiers (keys may include 'isbn'
70     * pointing to an ISBN object and 'issn' pointing to a string)
71     *
72     * @return string|bool
73     *
74     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
75     */
76    public function getUrl($key, $size, $ids)
77    {
78        // Don't bother trying if ISSN is missing:
79        if (!isset($ids['issn'])) {
80            return false;
81        }
82
83        $command = new LookupIssnsCommand('BrowZine', $ids['issn']);
84        $result = $this->searchService->invoke($command)->getResult();
85        return $result['data'][0]['coverImageUrl'] ?? false;
86    }
87}