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
TextBox
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
 writeInnerMargin
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
 writeBorder
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * This file is part of PHPWord - A pure PHP library for reading and writing
5 * word processing documents.
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 * For the full copyright and license information, please read the LICENSE
9 * file that was distributed with this source code. For the full list of
10 * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
11 *
12 * @see         https://github.com/PHPOffice/PHPWord
13 *
14 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
15 */
16
17namespace PhpOffice\PhpWord\Writer\Word2007\Style;
18
19use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle;
20
21/**
22 * TextBox style writer.
23 *
24 * @since 0.11.0
25 */
26class TextBox extends Frame
27{
28    /**
29     * Writer inner margin.
30     */
31    public function writeInnerMargin(): void
32    {
33        $style = $this->getStyle();
34        if (!$style instanceof TextBoxStyle || !$style->hasInnerMargins()) {
35            return;
36        }
37
38        $xmlWriter = $this->getXmlWriter();
39        $margins = implode(', ', $style->getInnerMargin());
40
41        $xmlWriter->writeAttribute('inset', $margins);
42    }
43
44    /**
45     * Writer border.
46     */
47    public function writeBorder(): void
48    {
49        $style = $this->getStyle();
50        if (!$style instanceof TextBoxStyle) {
51            return;
52        }
53        $xmlWriter = $this->getXmlWriter();
54
55        $xmlWriter->startElement('v:stroke');
56        $xmlWriter->writeAttributeIf($style->getBorderSize() !== null, 'weight', $style->getBorderSize() . 'pt');
57        $xmlWriter->writeAttributeIf($style->getBorderColor() !== null, 'color', $style->getBorderColor());
58        $xmlWriter->endElement(); // v:stroke
59    }
60}