Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
26 / 26
100.00% covered (success)
100.00%
17 / 17
CRAP
100.00% covered (success)
100.00%
1 / 1
TextBox
100.00% covered (success)
100.00%
26 / 26
100.00% covered (success)
100.00%
17 / 17
19
100.00% covered (success)
100.00%
1 / 1
 setBgColor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getBgColor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInnerMarginTop
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInnerMarginTop
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInnerMarginLeft
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInnerMarginLeft
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInnerMarginRight
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInnerMarginRight
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInnerMarginBottom
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInnerMarginBottom
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInnerMargin
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getInnerMargin
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasInnerMargins
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
 setBorderSize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getBorderSize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setBorderColor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getBorderColor
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 * PHPWord is free software distributed under the terms of the GNU Lesser
6 * General Public License version 3 as published by the Free Software Foundation.
7 * For the full copyright and license information, please read the LICENSE
8 * file that was distributed with this source code. For the full list of
9 * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
10 *
11 * @see         https://github.com/PHPOffice/PHPWord
12 *
13 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
14 */
15
16namespace PhpOffice\PhpWord\Style;
17
18/**
19 * TextBox style.
20 *
21 * @since 0.11.0
22 */
23class TextBox extends Image
24{
25    /**
26     * margin top.
27     *
28     * @var null|int
29     */
30    private $innerMarginTop;
31
32    /**
33     * margin left.
34     *
35     * @var null|int
36     */
37    private $innerMarginLeft;
38
39    /**
40     * margin right.
41     *
42     * @var null|int
43     */
44    private $innerMarginRight;
45
46    /**
47     * Cell margin bottom.
48     *
49     * @var null|int
50     */
51    private $innerMarginBottom;
52
53    /**
54     * border size.
55     *
56     * @var null|int
57     */
58    private $borderSize;
59
60    /**
61     * border color.
62     *
63     * @var null|string
64     */
65    private $borderColor;
66
67    /**
68     * background color.
69     *
70     * @var null|string
71     */
72    private $bgColor;
73
74    /**
75     * Set background color.
76     */
77    public function setBgColor(?string $value = null): void
78    {
79        $this->bgColor = $value;
80    }
81
82    /**
83     * Get background color.
84     */
85    public function getBgColor(): ?string
86    {
87        return $this->bgColor;
88    }
89
90    /**
91     * Set margin top.
92     */
93    public function setInnerMarginTop(?int $value = null): void
94    {
95        $this->innerMarginTop = $value;
96    }
97
98    /**
99     * Get margin top.
100     */
101    public function getInnerMarginTop(): ?int
102    {
103        return $this->innerMarginTop;
104    }
105
106    /**
107     * Set margin left.
108     */
109    public function setInnerMarginLeft(?int $value = null): void
110    {
111        $this->innerMarginLeft = $value;
112    }
113
114    /**
115     * Get margin left.
116     */
117    public function getInnerMarginLeft(): ?int
118    {
119        return $this->innerMarginLeft;
120    }
121
122    /**
123     * Set margin right.
124     */
125    public function setInnerMarginRight(?int $value = null): void
126    {
127        $this->innerMarginRight = $value;
128    }
129
130    /**
131     * Get margin right.
132     */
133    public function getInnerMarginRight(): ?int
134    {
135        return $this->innerMarginRight;
136    }
137
138    /**
139     * Set margin bottom.
140     */
141    public function setInnerMarginBottom(?int $value = null): void
142    {
143        $this->innerMarginBottom = $value;
144    }
145
146    /**
147     * Get margin bottom.
148     */
149    public function getInnerMarginBottom(): ?int
150    {
151        return $this->innerMarginBottom;
152    }
153
154    /**
155     * Set TLRB cell margin.
156     *
157     * @param null|int $value Margin in twips
158     */
159    public function setInnerMargin(?int $value = null): void
160    {
161        $this->setInnerMarginTop($value);
162        $this->setInnerMarginLeft($value);
163        $this->setInnerMarginRight($value);
164        $this->setInnerMarginBottom($value);
165    }
166
167    /**
168     * Get cell margin.
169     *
170     * @return int[]
171     */
172    public function getInnerMargin(): array
173    {
174        return [$this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom];
175    }
176
177    /**
178     * Has inner margin?
179     */
180    public function hasInnerMargins(): bool
181    {
182        $hasInnerMargins = false;
183        $margins = $this->getInnerMargin();
184        $numMargins = count($margins);
185        for ($i = 0; $i < $numMargins; ++$i) {
186            if ($margins[$i] !== null) {
187                $hasInnerMargins = true;
188            }
189        }
190
191        return $hasInnerMargins;
192    }
193
194    /**
195     * Set border size.
196     *
197     * @param null|int $value Size in points
198     */
199    public function setBorderSize(?int $value = null): void
200    {
201        $this->borderSize = $value;
202    }
203
204    /**
205     * Get border size.
206     */
207    public function getBorderSize(): ?int
208    {
209        return $this->borderSize;
210    }
211
212    /**
213     * Set border color.
214     */
215    public function setBorderColor(?string $value = null): void
216    {
217        $this->borderColor = $value;
218    }
219
220    /**
221     * Get border color.
222     */
223    public function getBorderColor(): ?string
224    {
225        return $this->borderColor;
226    }
227}