Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
BrowZine
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 6
110
0.00% covered (danger)
0.00%
0 / 1
 getShortTitle
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSjrValue
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTitle
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getThumbnail
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getISSNs
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
 getURLs
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3/**
4 * Model for BrowZine records.
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2017.
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
30namespace VuFind\RecordDriver;
31
32/**
33 * Model for BrowZine records.
34 *
35 * @category VuFind
36 * @package  RecordDrivers
37 * @author   Demian Katz <demian.katz@villanova.edu>
38 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
39 * @link     https://vufind.org/wiki/development:plugins:record_drivers Wiki
40 */
41class BrowZine extends DefaultRecord
42{
43    /**
44     * Get the short (pre-subtitle) title of the record.
45     *
46     * @return string
47     */
48    public function getShortTitle()
49    {
50        return $this->getTitle();
51    }
52
53    /**
54     * Get the SciMago Journal Rank
55     *
56     * @return string
57     */
58    public function getSjrValue()
59    {
60        return $this->fields['sjrValue'] ?? '';
61    }
62
63    /**
64     * Get the full title of the record.
65     *
66     * @return string
67     */
68    public function getTitle()
69    {
70        return $this->fields['name'] ?? parent::getTitle();
71    }
72
73    /**
74     * Returns one of three things: a full URL to a thumbnail preview of the record
75     * if an image is available in an external system; an array of parameters to
76     * send to VuFind's internal cover generator if no fixed URL exists; or false
77     * if no thumbnail can be generated.
78     *
79     * @param string $size Size of thumbnail (small, medium or large -- small is
80     * default).
81     *
82     * @return string|array|bool
83     */
84    public function getThumbnail($size = 'small')
85    {
86        if (isset($this->fields['coverImageUrl'])) {
87            return $this->fields['coverImageUrl'];
88        }
89        return parent::getThumbnail($size);
90    }
91
92    /**
93     * Get an array of all ISSNs associated with the record (may be empty).
94     *
95     * @return array
96     */
97    public function getISSNs()
98    {
99        return isset($this->fields['issn']) ? (array)$this->fields['issn'] : [];
100    }
101
102    /**
103     * Return an array of associative URL arrays with one or more of the following
104     * keys:
105     *
106     * <li>
107     *   <ul>desc: URL description text to display (optional)</ul>
108     *   <ul>url: fully-formed URL (required if 'route' is absent)</ul>
109     *   <ul>route: VuFind route to build URL with (required if 'url' is absent)</ul>
110     *   <ul>routeParams: Parameters for route (optional)</ul>
111     *   <ul>queryString: Query params to append after building route (optional)</ul>
112     * </li>
113     *
114     * @return array
115     */
116    public function getURLs()
117    {
118        $urls = [];
119        $fields = ['browzineWebLink', 'externalLink'];
120        foreach ($fields as $field) {
121            if (isset($this->fields[$field])) {
122                $urls[] = $this->fields[$field];
123            }
124        }
125        $filter = function ($url) {
126            return ['url' => $url];
127        };
128        return array_map($filter, $urls);
129    }
130}