Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.86% covered (success)
92.86%
13 / 14
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ListItemRun
92.86% covered (success)
92.86%
13 / 14
0.00% covered (danger)
0.00%
0 / 1
4.01
0.00% covered (danger)
0.00%
0 / 1
 write
92.86% covered (success)
92.86%
13 / 14
0.00% covered (danger)
0.00%
0 / 1
4.01
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
18namespace PhpOffice\PhpWord\Writer\ODText\Element;
19
20use PhpOffice\PhpWord\Element\ListItemRun as ListItemRunElement;
21
22/**
23 * ListItemRun element writer.
24 *
25 * @since 0.10.0
26 */
27class ListItemRun extends AbstractElement
28{
29    /**
30     * Write list item element.
31     */
32    public function write(): void
33    {
34        $element = $this->getElement();
35        if (!$element instanceof ListItemRunElement) {
36            return;
37        }
38        $depth = $element->getDepth() + 1;
39
40        $xmlWriter = $this->getXmlWriter();
41
42        for ($iDepth = 1; $iDepth <= $depth; ++$iDepth) {
43            $xmlWriter->startElement('text:list');
44            $xmlWriter->writeAttribute('text:style-name', $element->getStyle()->getNumStyle());
45            $xmlWriter->startElement('text:list-item');
46        }
47
48        $containerWriter = new Container($xmlWriter, $element, false);
49        $containerWriter->write();
50
51        for ($iDepth = 1; $iDepth <= $depth; ++$iDepth) {
52            $xmlWriter->endElement(); // text:list-item
53            $xmlWriter->endElement(); // text:list
54        }
55    }
56}