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