Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.00% covered (success)
90.00%
9 / 10
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Formula
90.00% covered (success)
90.00%
9 / 10
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 1
 write
90.00% covered (success)
90.00%
9 / 10
0.00% covered (danger)
0.00%
0 / 1
2.00
1<?php
2
3/**
4 * This file is part of PHPWord - A pure PHP library for reading and writing
5 * word processing documents.
6 *
7 * PHPWord is free software distributed under the terms of the GNU Lesser
8 * General Public License version 3 as published by the Free Software Foundation.
9 *
10 * For the full copyright and license information, please read the LICENSE
11 * file that was distributed with this source code. For the full list of
12 * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
13 *
14 * @see         https://github.com/PHPOffice/PHPWord
15 *
16 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
17 */
18
19namespace PhpOffice\PhpWord\Writer\Word2007\Element;
20
21use PhpOffice\Math\Writer\OfficeMathML;
22use PhpOffice\PhpWord\Element\Formula as FormulaElement;
23
24/**
25 * Formula element writer.
26 */
27class Formula extends AbstractElement
28{
29    /**
30     * Write element.
31     */
32    public function write(): void
33    {
34        $element = $this->getElement();
35        if (!$element instanceof FormulaElement) {
36            return;
37        }
38
39        $this->startElementP();
40
41        $xmlWriter = $this->getXmlWriter();
42
43        $xmlWriter->startElement('w:r');
44        $xmlWriter->writeElement('w:rPr');
45        $xmlWriter->endElement();
46
47        $xmlWriter->writeRaw((new OfficeMathML())->write($element->getMath()));
48
49        $this->endElementP();
50    }
51}