Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Row
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 write
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
4
 setHeight
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
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\Style;
20
21/**
22 * Row style writer.
23 *
24 * @since 0.11.0
25 */
26class Row extends AbstractStyle
27{
28    /**
29     * @var int Row height
30     */
31    private $height;
32
33    /**
34     * Write style.
35     */
36    public function write(): void
37    {
38        $style = $this->getStyle();
39        if (!$style instanceof \PhpOffice\PhpWord\Style\Row) {
40            return;
41        }
42
43        $xmlWriter = $this->getXmlWriter();
44        $xmlWriter->startElement('w:trPr');
45
46        if ($this->height !== null) {
47            $xmlWriter->startElement('w:trHeight');
48            $xmlWriter->writeAttribute('w:val', $this->height);
49            $xmlWriter->writeAttribute('w:hRule', ($style->isExactHeight() ? 'exact' : 'atLeast'));
50            $xmlWriter->endElement();
51        }
52        $xmlWriter->writeElementIf($style->isTblHeader(), 'w:tblHeader', 'w:val', '1');
53        $xmlWriter->writeElementIf($style->isCantSplit(), 'w:cantSplit', 'w:val', '1');
54
55        $xmlWriter->endElement(); // w:trPr
56    }
57
58    /**
59     * Set height.
60     *
61     * @param int $value
62     */
63    public function setHeight($value = null): void
64    {
65        $this->height = $value;
66    }
67}