Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Text | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
9 | |
100.00% |
1 / 1 |
write | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
9 |
1 | <?php |
2 | |
3 | namespace PhpOffice\PhpWord\Writer\EPub3\Element; |
4 | |
5 | /** |
6 | * Text element writer for EPub3. |
7 | */ |
8 | class Text extends AbstractElement |
9 | { |
10 | /** |
11 | * Write element. |
12 | */ |
13 | public function write(): void |
14 | { |
15 | $xmlWriter = $this->getXmlWriter(); |
16 | $xmlWriter->setIndent(true); |
17 | $xmlWriter->setIndentString(' '); |
18 | $element = $this->getElement(); |
19 | if (!$element instanceof \PhpOffice\PhpWord\Element\Text) { |
20 | return; |
21 | } |
22 | |
23 | $fontStyle = $element->getFontStyle(); |
24 | $paragraphStyle = $element->getParagraphStyle(); |
25 | |
26 | if (!$this->withoutP) { |
27 | $xmlWriter->startElement('p'); |
28 | if (is_string($paragraphStyle) && $paragraphStyle !== '') { |
29 | $xmlWriter->writeAttribute('class', $paragraphStyle); |
30 | } |
31 | } |
32 | |
33 | if (!empty($fontStyle)) { |
34 | $xmlWriter->startElement('span'); |
35 | if (is_string($fontStyle)) { |
36 | $xmlWriter->writeAttribute('class', $fontStyle); |
37 | } |
38 | } |
39 | |
40 | $xmlWriter->text($element->getText()); |
41 | |
42 | if (!empty($fontStyle)) { |
43 | $xmlWriter->endElement(); // span |
44 | } |
45 | |
46 | if (!$this->withoutP) { |
47 | $xmlWriter->endElement(); // p |
48 | } |
49 | } |
50 | } |