Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
8.70% covered (danger)
8.70%
2 / 23
25.00% covered (danger)
25.00%
2 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
Sample
8.70% covered (danger)
8.70%
2 / 23
25.00% covered (danger)
25.00%
2 / 8
70.65
0.00% covered (danger)
0.00%
0 / 1
 init
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getStatus
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
 getStatuses
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 getHolding
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPurchaseHistory
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNewItems
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 findReserves
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 patronLogin
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * Lightweight Dummy ILS Driver -- Always returns hard-coded sample values.
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2007.
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  ILS_Drivers
25 * @author   Andrew S. Nagy <vufind-tech@lists.sourceforge.net>
26 * @author   Demian Katz <demian.katz@villanova.edu>
27 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
28 * @link     https://vufind.org/wiki/development:plugins:ils_drivers Wiki
29 */
30
31namespace VuFind\ILS\Driver;
32
33/**
34 * Lightweight Dummy ILS Driver -- Always returns hard-coded sample values.
35 *
36 * @category VuFind
37 * @package  ILS_Drivers
38 * @author   Andrew S. Nagy <vufind-tech@lists.sourceforge.net>
39 * @author   Demian Katz <demian.katz@villanova.edu>
40 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
41 * @link     https://vufind.org/wiki/development:plugins:ils_drivers Wiki
42 */
43class Sample extends AbstractBase
44{
45    /**
46     * Initialize the driver.
47     *
48     * Validate configuration and perform all resource-intensive tasks needed to
49     * make the driver active.
50     *
51     * @return void
52     */
53    public function init()
54    {
55        // Sample driver doesn't care about configuration.
56    }
57
58    /**
59     * Get Status
60     *
61     * This is responsible for retrieving the status information of a certain
62     * record.
63     *
64     * @param string $id The record id to retrieve the holdings for
65     *
66     * @return mixed     On success, an associative array with the following keys:
67     * id, availability (boolean), status, location, reserve, callnumber.
68     */
69    public function getStatus($id)
70    {
71        return [
72            [
73                'id' => $id,
74                'availability' => 1,
75                'status' => 'Available',
76                'location' => '3rd Floor Main Library',
77                'reserve' => 'N',
78                'callnumber' => 'A1234.567',
79                'duedate' => '',
80                'number' => 1,
81                'barcode' => '1234567890',
82            ],
83        ];
84    }
85
86    /**
87     * Get Statuses
88     *
89     * This is responsible for retrieving the status information for a
90     * collection of records.
91     *
92     * @param array $ids The array of record ids to retrieve the status for
93     *
94     * @return mixed     An array of getStatus() return values on success.
95     */
96    public function getStatuses($ids)
97    {
98        $items = [];
99        foreach ($ids as $id) {
100            $items[] = $this->getStatus($id);
101        }
102        return $items;
103    }
104
105    /**
106     * Get Holding
107     *
108     * This is responsible for retrieving the holding information of a certain
109     * record.
110     *
111     * @param string $id      The record id to retrieve the holdings for
112     * @param array  $patron  Patron data
113     * @param array  $options Extra options (not currently used)
114     *
115     * @return mixed     On success, an associative array with the following keys:
116     * id, availability (boolean), status, location, reserve, callnumber, duedate,
117     * number, barcode.
118     *
119     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
120     */
121    public function getHolding($id, array $patron = null, array $options = [])
122    {
123        return $this->getStatus($id);
124    }
125
126    /**
127     * Get Purchase History
128     *
129     * This is responsible for retrieving the acquisitions history data for the
130     * specific record (usually recently received issues of a serial).
131     *
132     * @param string $id The record id to retrieve the info for
133     *
134     * @return mixed     An array with the acquisitions data on success.
135     *
136     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
137     */
138    public function getPurchaseHistory($id)
139    {
140        return [];
141    }
142
143    /**
144     * Get New Items
145     *
146     * Retrieve the IDs of items recently added to the catalog.
147     *
148     * @param int $page    Page number of results to retrieve (counting starts at 1)
149     * @param int $limit   The size of each page of results to retrieve
150     * @param int $daysOld The maximum age of records to retrieve in days (max. 30)
151     * @param int $fundId  optional fund ID to use for limiting results (use a value
152     * returned by getFunds, or exclude for no limit); note that "fund" may be a
153     * misnomer - if funds are not an appropriate way to limit your new item
154     * results, you can return a different set of values from getFunds. The
155     * important thing is that this parameter supports an ID returned by getFunds,
156     * whatever that may mean.
157     *
158     * @return array       Associative array with 'count' and 'results' keys
159     *
160     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
161     */
162    public function getNewItems($page, $limit, $daysOld, $fundId = null)
163    {
164        return ['count' => 0, 'results' => []];
165    }
166
167    /**
168     * Find Reserves
169     *
170     * Obtain information on course reserves.
171     *
172     * @param string $course ID from getCourses (empty string to match all)
173     * @param string $inst   ID from getInstructors (empty string to match all)
174     * @param string $dept   ID from getDepartments (empty string to match all)
175     *
176     * @return mixed An array of associative arrays representing reserve items.
177     *
178     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
179     */
180    public function findReserves($course, $inst, $dept)
181    {
182        return [];
183    }
184
185    /**
186     * Patron Login
187     *
188     * This is responsible for authenticating a patron against the catalog.
189     *
190     * @param string $username The patron username
191     * @param string $password The patron password
192     *
193     * @return mixed           Associative array of patron info on successful login,
194     * null on unsuccessful login.
195     *
196     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
197     */
198    public function patronLogin($username, $password)
199    {
200        return null;
201    }
202}