Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
SolrAuthMarc
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getRawLCCN
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3/**
4 * Model for MARC authority records in Solr.
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2010.
9 * Copyright (C) The National Library of Finland 2015.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2,
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 *
24 * @category VuFind
25 * @package  RecordDrivers
26 * @author   Demian Katz <demian.katz@villanova.edu>
27 * @author   Ere Maijala <ere.maijala@helsinki.fi>
28 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
29 * @link     https://vufind.org/wiki/development:plugins:record_drivers Wiki
30 */
31
32namespace VuFind\RecordDriver;
33
34/**
35 * Model for MARC authority records in Solr.
36 *
37 * @category VuFind
38 * @package  RecordDrivers
39 * @author   Demian Katz <demian.katz@villanova.edu>
40 * @author   Ere Maijala <ere.maijala@helsinki.fi>
41 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
42 * @link     https://vufind.org/wiki/development:plugins:record_drivers Wiki
43 */
44class SolrAuthMarc extends SolrAuthDefault
45{
46    use Feature\MarcReaderTrait;
47    use Feature\MarcAdvancedTrait;
48
49    /**
50     * Constructor
51     *
52     * @param \Laminas\Config\Config $mainConfig     VuFind main configuration (omit
53     * for built-in defaults)
54     * @param \Laminas\Config\Config $recordConfig   Record-specific configuration
55     * file (omit to use $mainConfig as $recordConfig)
56     * @param \Laminas\Config\Config $searchSettings Search-specific configuration
57     * file
58     */
59    public function __construct(
60        $mainConfig = null,
61        $recordConfig = null,
62        $searchSettings = null
63    ) {
64        parent::__construct($mainConfig, $recordConfig, $searchSettings);
65        $this->xmlType = 'Authority';
66    }
67
68    /**
69     * Get a raw LCCN (not normalized). Returns false if none available.
70     *
71     * @return string|bool
72     */
73    public function getRawLCCN()
74    {
75        $lccn = $this->getFirstFieldValue('010');
76        if (!empty($lccn)) {
77            return $lccn;
78        }
79        $lccns = $this->getFieldArray('700', ['0']);
80        foreach ($lccns as $lccn) {
81            if (str_starts_with($lccn, '(DLC)')) {
82                return substr($lccn, 5);
83            }
84        }
85        return false;
86    }
87}