Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.33% covered (success)
93.33%
14 / 15
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Line
93.33% covered (success)
93.33%
14 / 15
0.00% covered (danger)
0.00%
0 / 1
3.00
0.00% covered (danger)
0.00%
0 / 1
 write
93.33% covered (success)
93.33%
14 / 15
0.00% covered (danger)
0.00%
0 / 1
3.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 view 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 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
15 */
16
17namespace PhpOffice\PhpWord\Writer\ODText\Style;
18
19use PhpOffice\PhpWord\Style\Line as LineStyle;
20
21/**
22 * Line style writer.
23 */
24class Line extends AbstractStyle
25{
26    public function write(): void
27    {
28        $style = $this->getStyle();
29        if (!$style instanceof LineStyle) {
30            return;
31        }
32
33        $xmlWriter = $this->getXmlWriter();
34        $xmlWriter->startElement('style:style');
35        $xmlWriter->writeAttribute('style:name', $style->getStyleName());
36        $xmlWriter->writeAttribute('style:family', 'graphic');
37        $xmlWriter->writeAttribute('style:parent-style-name', 'Graphics');
38        $xmlWriter->startElement('style:graphic-properties');
39        $xmlWriter->writeAttribute('draw:stroke', 'solid');
40        if ($style->getColor() !== null) {
41            $xmlWriter->writeAttribute('svg:stroke-color', '#' . ltrim($style->getColor(), '#'));
42        }
43        $xmlWriter->writeAttributeIf($style->getWeight() !== null, 'svg:stroke-width', $style->getWeight() . 'pt');
44        $xmlWriter->endElement(); // style:graphic-properties
45        $xmlWriter->endElement(); // style:style
46    }
47}