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