Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
83 / 83 |
|
100.00% |
39 / 39 |
CRAP | |
100.00% |
1 / 1 |
Border | |
100.00% |
83 / 83 |
|
100.00% |
39 / 39 |
39 | |
100.00% |
1 / 1 |
getBorderSize | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
setBorderSize | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
getBorderColor | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
setBorderColor | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
getBorderStyle | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
setBorderStyle | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
getBorderTopSize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderTopSize | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderTopColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderTopColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderTopStyle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderTopStyle | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderLeftSize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderLeftSize | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderLeftColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderLeftColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderLeftStyle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderLeftStyle | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderRightSize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderRightSize | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderRightColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderRightColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderRightStyle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderRightStyle | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderBottomSize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderBottomSize | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderBottomColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderBottomColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBorderBottomStyle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBorderBottomStyle | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
hasBorder | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getMarginTop | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMarginTop | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getMarginLeft | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMarginLeft | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getMarginRight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMarginRight | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getMarginBottom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMarginBottom | |
100.00% |
2 / 2 |
|
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 | |
19 | namespace PhpOffice\PhpWord\Style; |
20 | |
21 | /** |
22 | * Border style. |
23 | */ |
24 | class Border extends AbstractStyle |
25 | { |
26 | const DEFAULT_MARGIN = 1440; // In twips. |
27 | |
28 | /** |
29 | * Border Top Size. |
30 | * |
31 | * @var float|int |
32 | */ |
33 | protected $borderTopSize; |
34 | |
35 | /** |
36 | * Border Top Color. |
37 | * |
38 | * @var null|string |
39 | */ |
40 | protected $borderTopColor; |
41 | |
42 | /** |
43 | * Border Top Style. |
44 | * |
45 | * @var string |
46 | */ |
47 | protected $borderTopStyle; |
48 | |
49 | /** |
50 | * Border Left Size. |
51 | * |
52 | * @var float|int |
53 | */ |
54 | protected $borderLeftSize; |
55 | |
56 | /** |
57 | * Border Left Color. |
58 | * |
59 | * @var null|string |
60 | */ |
61 | protected $borderLeftColor; |
62 | |
63 | /** |
64 | * Border Left Style. |
65 | * |
66 | * @var string |
67 | */ |
68 | protected $borderLeftStyle; |
69 | |
70 | /** |
71 | * Border Right Size. |
72 | * |
73 | * @var float|int |
74 | */ |
75 | protected $borderRightSize; |
76 | |
77 | /** |
78 | * Border Right Color. |
79 | * |
80 | * @var null|string |
81 | */ |
82 | protected $borderRightColor; |
83 | |
84 | /** |
85 | * Border Right Style. |
86 | * |
87 | * @var string |
88 | */ |
89 | protected $borderRightStyle; |
90 | |
91 | /** |
92 | * Border Bottom Size. |
93 | * |
94 | * @var float|int |
95 | */ |
96 | protected $borderBottomSize; |
97 | |
98 | /** |
99 | * Border Bottom Color. |
100 | * |
101 | * @var null|string |
102 | */ |
103 | protected $borderBottomColor; |
104 | |
105 | /** |
106 | * Border Bottom Style. |
107 | * |
108 | * @var string |
109 | */ |
110 | protected $borderBottomStyle; |
111 | |
112 | /** |
113 | * Top margin spacing. |
114 | * |
115 | * @var float|int |
116 | */ |
117 | protected $marginTop = self::DEFAULT_MARGIN; |
118 | |
119 | /** |
120 | * Left margin spacing. |
121 | * |
122 | * @var float|int |
123 | */ |
124 | protected $marginLeft = self::DEFAULT_MARGIN; |
125 | |
126 | /** |
127 | * Right margin spacing. |
128 | * |
129 | * @var float|int |
130 | */ |
131 | protected $marginRight = self::DEFAULT_MARGIN; |
132 | |
133 | /** |
134 | * Bottom margin spacing. |
135 | * |
136 | * @var float|int |
137 | */ |
138 | protected $marginBottom = self::DEFAULT_MARGIN; |
139 | |
140 | /** |
141 | * Get border size. |
142 | * |
143 | * @return int[] |
144 | */ |
145 | public function getBorderSize() |
146 | { |
147 | return [ |
148 | $this->getBorderTopSize(), |
149 | $this->getBorderLeftSize(), |
150 | $this->getBorderRightSize(), |
151 | $this->getBorderBottomSize(), |
152 | ]; |
153 | } |
154 | |
155 | /** |
156 | * Set border size. |
157 | * |
158 | * @param float|int $value |
159 | * |
160 | * @return self |
161 | */ |
162 | public function setBorderSize($value = null) |
163 | { |
164 | $this->setBorderTopSize($value); |
165 | $this->setBorderLeftSize($value); |
166 | $this->setBorderRightSize($value); |
167 | $this->setBorderBottomSize($value); |
168 | |
169 | return $this; |
170 | } |
171 | |
172 | /** |
173 | * Get border color. |
174 | * |
175 | * @return array<null|string> |
176 | */ |
177 | public function getBorderColor() |
178 | { |
179 | return [ |
180 | $this->getBorderTopColor(), |
181 | $this->getBorderLeftColor(), |
182 | $this->getBorderRightColor(), |
183 | $this->getBorderBottomColor(), |
184 | ]; |
185 | } |
186 | |
187 | /** |
188 | * Set border color. |
189 | * |
190 | * @param null|string $value |
191 | * |
192 | * @return self |
193 | */ |
194 | public function setBorderColor($value = null) |
195 | { |
196 | $this->setBorderTopColor($value); |
197 | $this->setBorderLeftColor($value); |
198 | $this->setBorderRightColor($value); |
199 | $this->setBorderBottomColor($value); |
200 | |
201 | return $this; |
202 | } |
203 | |
204 | /** |
205 | * Get border style. |
206 | * |
207 | * @return string[] |
208 | */ |
209 | public function getBorderStyle() |
210 | { |
211 | return [ |
212 | $this->getBorderTopStyle(), |
213 | $this->getBorderLeftStyle(), |
214 | $this->getBorderRightStyle(), |
215 | $this->getBorderBottomStyle(), |
216 | ]; |
217 | } |
218 | |
219 | /** |
220 | * Set border style. |
221 | * |
222 | * @param string $value |
223 | * |
224 | * @return self |
225 | */ |
226 | public function setBorderStyle($value = null) |
227 | { |
228 | $this->setBorderTopStyle($value); |
229 | $this->setBorderLeftStyle($value); |
230 | $this->setBorderRightStyle($value); |
231 | $this->setBorderBottomStyle($value); |
232 | |
233 | return $this; |
234 | } |
235 | |
236 | /** |
237 | * Get border top size. |
238 | * |
239 | * @return float|int |
240 | */ |
241 | public function getBorderTopSize() |
242 | { |
243 | return $this->borderTopSize; |
244 | } |
245 | |
246 | /** |
247 | * Set border top size. |
248 | * |
249 | * @param float|int $value |
250 | * |
251 | * @return self |
252 | */ |
253 | public function setBorderTopSize($value = null) |
254 | { |
255 | $this->borderTopSize = $this->setNumericVal($value, $this->borderTopSize); |
256 | |
257 | return $this; |
258 | } |
259 | |
260 | /** |
261 | * Get border top color. |
262 | * |
263 | * @return null|string |
264 | */ |
265 | public function getBorderTopColor() |
266 | { |
267 | return $this->borderTopColor; |
268 | } |
269 | |
270 | /** |
271 | * Set border top color. |
272 | * |
273 | * @param null|string $value |
274 | * |
275 | * @return self |
276 | */ |
277 | public function setBorderTopColor($value = null) |
278 | { |
279 | $this->borderTopColor = $value; |
280 | |
281 | return $this; |
282 | } |
283 | |
284 | /** |
285 | * Get border top style. |
286 | * |
287 | * @return string |
288 | */ |
289 | public function getBorderTopStyle() |
290 | { |
291 | return $this->borderTopStyle; |
292 | } |
293 | |
294 | /** |
295 | * Set border top Style. |
296 | * |
297 | * @param string $value |
298 | * |
299 | * @return self |
300 | */ |
301 | public function setBorderTopStyle($value = null) |
302 | { |
303 | $this->borderTopStyle = $value; |
304 | |
305 | return $this; |
306 | } |
307 | |
308 | /** |
309 | * Get border left size. |
310 | * |
311 | * @return float|int |
312 | */ |
313 | public function getBorderLeftSize() |
314 | { |
315 | return $this->borderLeftSize; |
316 | } |
317 | |
318 | /** |
319 | * Set border left size. |
320 | * |
321 | * @param float|int $value |
322 | * |
323 | * @return self |
324 | */ |
325 | public function setBorderLeftSize($value = null) |
326 | { |
327 | $this->borderLeftSize = $this->setNumericVal($value, $this->borderLeftSize); |
328 | |
329 | return $this; |
330 | } |
331 | |
332 | /** |
333 | * Get border left color. |
334 | * |
335 | * @return null|string |
336 | */ |
337 | public function getBorderLeftColor() |
338 | { |
339 | return $this->borderLeftColor; |
340 | } |
341 | |
342 | /** |
343 | * Set border left color. |
344 | * |
345 | * @param null|string $value |
346 | * |
347 | * @return self |
348 | */ |
349 | public function setBorderLeftColor($value = null) |
350 | { |
351 | $this->borderLeftColor = $value; |
352 | |
353 | return $this; |
354 | } |
355 | |
356 | /** |
357 | * Get border left style. |
358 | * |
359 | * @return string |
360 | */ |
361 | public function getBorderLeftStyle() |
362 | { |
363 | return $this->borderLeftStyle; |
364 | } |
365 | |
366 | /** |
367 | * Set border left style. |
368 | * |
369 | * @param string $value |
370 | * |
371 | * @return self |
372 | */ |
373 | public function setBorderLeftStyle($value = null) |
374 | { |
375 | $this->borderLeftStyle = $value; |
376 | |
377 | return $this; |
378 | } |
379 | |
380 | /** |
381 | * Get border right size. |
382 | * |
383 | * @return float|int |
384 | */ |
385 | public function getBorderRightSize() |
386 | { |
387 | return $this->borderRightSize; |
388 | } |
389 | |
390 | /** |
391 | * Set border right size. |
392 | * |
393 | * @param float|int $value |
394 | * |
395 | * @return self |
396 | */ |
397 | public function setBorderRightSize($value = null) |
398 | { |
399 | $this->borderRightSize = $this->setNumericVal($value, $this->borderRightSize); |
400 | |
401 | return $this; |
402 | } |
403 | |
404 | /** |
405 | * Get border right color. |
406 | * |
407 | * @return null|string |
408 | */ |
409 | public function getBorderRightColor() |
410 | { |
411 | return $this->borderRightColor; |
412 | } |
413 | |
414 | /** |
415 | * Set border right color. |
416 | * |
417 | * @param null|string $value |
418 | * |
419 | * @return self |
420 | */ |
421 | public function setBorderRightColor($value = null) |
422 | { |
423 | $this->borderRightColor = $value; |
424 | |
425 | return $this; |
426 | } |
427 | |
428 | /** |
429 | * Get border right style. |
430 | * |
431 | * @return string |
432 | */ |
433 | public function getBorderRightStyle() |
434 | { |
435 | return $this->borderRightStyle; |
436 | } |
437 | |
438 | /** |
439 | * Set border right style. |
440 | * |
441 | * @param string $value |
442 | * |
443 | * @return self |
444 | */ |
445 | public function setBorderRightStyle($value = null) |
446 | { |
447 | $this->borderRightStyle = $value; |
448 | |
449 | return $this; |
450 | } |
451 | |
452 | /** |
453 | * Get border bottom size. |
454 | * |
455 | * @return float|int |
456 | */ |
457 | public function getBorderBottomSize() |
458 | { |
459 | return $this->borderBottomSize; |
460 | } |
461 | |
462 | /** |
463 | * Set border bottom size. |
464 | * |
465 | * @param float|int $value |
466 | * |
467 | * @return self |
468 | */ |
469 | public function setBorderBottomSize($value = null) |
470 | { |
471 | $this->borderBottomSize = $this->setNumericVal($value, $this->borderBottomSize); |
472 | |
473 | return $this; |
474 | } |
475 | |
476 | /** |
477 | * Get border bottom color. |
478 | * |
479 | * @return null|string |
480 | */ |
481 | public function getBorderBottomColor() |
482 | { |
483 | return $this->borderBottomColor; |
484 | } |
485 | |
486 | /** |
487 | * Set border bottom color. |
488 | * |
489 | * @param null|string $value |
490 | * |
491 | * @return self |
492 | */ |
493 | public function setBorderBottomColor($value = null) |
494 | { |
495 | $this->borderBottomColor = $value; |
496 | |
497 | return $this; |
498 | } |
499 | |
500 | /** |
501 | * Get border bottom style. |
502 | * |
503 | * @return string |
504 | */ |
505 | public function getBorderBottomStyle() |
506 | { |
507 | return $this->borderBottomStyle; |
508 | } |
509 | |
510 | /** |
511 | * Set border bottom style. |
512 | * |
513 | * @param string $value |
514 | * |
515 | * @return self |
516 | */ |
517 | public function setBorderBottomStyle($value = null) |
518 | { |
519 | $this->borderBottomStyle = $value; |
520 | |
521 | return $this; |
522 | } |
523 | |
524 | /** |
525 | * Check if any of the border is not null. |
526 | * |
527 | * @return bool |
528 | */ |
529 | public function hasBorder() |
530 | { |
531 | $borders = $this->getBorderSize(); |
532 | |
533 | return $borders !== array_filter($borders, 'is_null'); |
534 | } |
535 | |
536 | /** |
537 | * Get Margin Top. |
538 | * |
539 | * @return float|int |
540 | */ |
541 | public function getMarginTop() |
542 | { |
543 | return $this->marginTop; |
544 | } |
545 | |
546 | /** |
547 | * Set Margin Top. |
548 | * |
549 | * @param float|int $value |
550 | * |
551 | * @return self |
552 | */ |
553 | public function setMarginTop($value = null) |
554 | { |
555 | $this->marginTop = $this->setNumericVal($value, self::DEFAULT_MARGIN); |
556 | |
557 | return $this; |
558 | } |
559 | |
560 | /** |
561 | * Get Margin Left. |
562 | * |
563 | * @return float|int |
564 | */ |
565 | public function getMarginLeft() |
566 | { |
567 | return $this->marginLeft; |
568 | } |
569 | |
570 | /** |
571 | * Set Margin Left. |
572 | * |
573 | * @param float|int $value |
574 | * |
575 | * @return self |
576 | */ |
577 | public function setMarginLeft($value = null) |
578 | { |
579 | $this->marginLeft = $this->setNumericVal($value, self::DEFAULT_MARGIN); |
580 | |
581 | return $this; |
582 | } |
583 | |
584 | /** |
585 | * Get Margin Right. |
586 | * |
587 | * @return float|int |
588 | */ |
589 | public function getMarginRight() |
590 | { |
591 | return $this->marginRight; |
592 | } |
593 | |
594 | /** |
595 | * Set Margin Right. |
596 | * |
597 | * @param float|int $value |
598 | * |
599 | * @return self |
600 | */ |
601 | public function setMarginRight($value = null) |
602 | { |
603 | $this->marginRight = $this->setNumericVal($value, self::DEFAULT_MARGIN); |
604 | |
605 | return $this; |
606 | } |
607 | |
608 | /** |
609 | * Get Margin Bottom. |
610 | * |
611 | * @return float|int |
612 | */ |
613 | public function getMarginBottom() |
614 | { |
615 | return $this->marginBottom; |
616 | } |
617 | |
618 | /** |
619 | * Set Margin Bottom. |
620 | * |
621 | * @param float|int $value |
622 | * |
623 | * @return self |
624 | */ |
625 | public function setMarginBottom($value = null) |
626 | { |
627 | $this->marginBottom = $this->setNumericVal($value, self::DEFAULT_MARGIN); |
628 | |
629 | return $this; |
630 | } |
631 | } |