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