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