Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Footnote | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
write | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * This file is part of PHPWord - A pure PHP library for reading and writing |
4 | * word processing documents. |
5 | * |
6 | * PHPWord is free software distributed under the terms of the GNU Lesser |
7 | * General Public License version 3 as published by the Free Software Foundation. |
8 | * |
9 | * For the full copyright and license information, please read the LICENSE |
10 | * file that was distributed with this source code. For the full list of |
11 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
12 | * |
13 | * @see https://github.com/PHPOffice/PHPWord |
14 | * |
15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16 | */ |
17 | |
18 | namespace PhpOffice\PhpWord\Writer\HTML\Element; |
19 | |
20 | /** |
21 | * Footnote element HTML writer. |
22 | * |
23 | * @since 0.10.0 |
24 | */ |
25 | class Footnote extends AbstractElement |
26 | { |
27 | /** |
28 | * Note type footnote|endnote. |
29 | * |
30 | * @var string |
31 | */ |
32 | protected $noteType = 'footnote'; |
33 | |
34 | /** |
35 | * Write footnote/endnote marks; The actual content is written in parent writer (HTML). |
36 | * |
37 | * @return string |
38 | */ |
39 | public function write() |
40 | { |
41 | if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) { |
42 | return ''; |
43 | } |
44 | /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ |
45 | $parentWriter = $this->parentWriter; |
46 | |
47 | $noteId = count($parentWriter->getNotes()) + 1; |
48 | $noteMark = $this->noteType . '-' . $this->element->getRelationId(); |
49 | $content = "<a name=\"{$noteMark}\"><a href=\"#note-{$noteId}\" class=\"NoteRef\"><sup>{$noteId}</sup></a>"; |
50 | |
51 | $parentWriter->addNote($noteId, $noteMark); |
52 | |
53 | return $content; |
54 | } |
55 | } |