Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
IniReaderTrait | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
getIniReader | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Trait for creating INI readers |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Hebis Verbundzentrale 2023. |
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 Config |
25 | * @author Thomas Wagener <wagener@hebis.uni-frankfurt.de> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org Main Site |
28 | */ |
29 | |
30 | namespace VuFind\Config\Feature; |
31 | |
32 | use Laminas\Config\Reader\Ini as IniReader; |
33 | |
34 | use function chr; |
35 | |
36 | /** |
37 | * Trait for creating INI readers |
38 | * |
39 | * @category VuFind |
40 | * @package Config |
41 | * @author Thomas Wagener <wagener@hebis.uni-frankfurt.de> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org Main Site |
44 | */ |
45 | trait IniReaderTrait |
46 | { |
47 | /** |
48 | * INI reader |
49 | * |
50 | * @var IniReader |
51 | */ |
52 | protected $iniReader = null; |
53 | |
54 | /** |
55 | * Creates INI reader if it does not exist and returns it. |
56 | * |
57 | * @return IniReader |
58 | */ |
59 | protected function getIniReader() |
60 | { |
61 | if (null == $this->iniReader) { |
62 | // Use ASCII 0 as a nest separator; otherwise some of the unusual key names |
63 | // we have (i.e. in WorldCat.ini search options) will get parsed in |
64 | // unexpected ways. |
65 | $this->iniReader = new IniReader(); |
66 | $this->iniReader->setNestSeparator(chr(0)); |
67 | } |
68 | return $this->iniReader; |
69 | } |
70 | } |