Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
86.36% |
19 / 22 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
Entry | |
86.36% |
19 / 22 |
|
0.00% |
0 / 3 |
7.12 | |
0.00% |
0 / 1 |
render | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
2.03 | |||
setDCFormats | |
88.89% |
8 / 9 |
|
0.00% |
0 / 1 |
3.01 | |||
setDCDate | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
2.01 |
1 | <?php |
2 | |
3 | /** |
4 | * Laminas\Feed\Renderer\Entry extension for Dublin Core |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
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 Feed_Plugins |
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 | |
30 | namespace VuFind\Feed\Writer\Extension\DublinCore\Renderer; |
31 | |
32 | use DOMDocument; |
33 | use DOMElement; |
34 | use Laminas\Feed\Writer\Extension\DublinCore\Renderer\Entry as ParentEntry; |
35 | |
36 | /** |
37 | * Laminas\Feed\Renderer\Entry extension for Dublin Core |
38 | * |
39 | * @category VuFind |
40 | * @package Feed_Plugins |
41 | * @author Demian Katz <demian.katz@villanova.edu> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org/wiki/development Wiki |
44 | */ |
45 | class Entry extends ParentEntry |
46 | { |
47 | /** |
48 | * Render entry |
49 | * |
50 | * @return void |
51 | */ |
52 | public function render() |
53 | { |
54 | if (strtolower($this->getType()) == 'atom') { |
55 | return; |
56 | } |
57 | $this->setDCFormats($this->dom, $this->base); |
58 | $this->setDCDate($this->dom, $this->base); |
59 | parent::render(); |
60 | } |
61 | |
62 | /** |
63 | * Set entry format elements |
64 | * |
65 | * @param DOMDocument $dom DOM document to update |
66 | * @param DOMElement $root Root of DOM document |
67 | * |
68 | * @return void |
69 | */ |
70 | protected function setDCFormats(DOMDocument $dom, DOMElement $root) |
71 | { |
72 | $dcFormats = $this->getDataContainer()->getDCFormats(); |
73 | if (empty($dcFormats)) { |
74 | return; |
75 | } |
76 | foreach ($dcFormats as $data) { |
77 | $format = $this->dom->createElement('dc:format'); |
78 | $text = $dom->createTextNode($data); |
79 | $format->appendChild($text); |
80 | $root->appendChild($format); |
81 | } |
82 | $this->called = true; |
83 | } |
84 | |
85 | /** |
86 | * Set entry date elements |
87 | * |
88 | * @param DOMDocument $dom DOM document to update |
89 | * @param DOMElement $root Root of DOM document |
90 | * |
91 | * @return void |
92 | */ |
93 | protected function setDCDate(DOMDocument $dom, DOMElement $root) |
94 | { |
95 | $dcDate = $this->getDataContainer()->getDCDate(); |
96 | if (empty($dcDate)) { |
97 | return; |
98 | } |
99 | $date = $this->dom->createElement('dc:date'); |
100 | $text = $dom->createTextNode($dcDate); |
101 | $date->appendChild($text); |
102 | $root->appendChild($date); |
103 | $this->called = true; |
104 | } |
105 | } |