Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
14 / 14 |
|
100.00% |
9 / 9 |
CRAP | |
100.00% |
1 / 1 |
Spacing | |
100.00% |
14 / 14 |
|
100.00% |
9 / 9 |
9 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getBefore | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBefore | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getAfter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAfter | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getLine | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLine | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getLineRule | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLineRule | |
100.00% |
3 / 3 |
|
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 | use PhpOffice\PhpWord\SimpleType\LineSpacingRule; |
21 | |
22 | /** |
23 | * Spacing between lines and above/below paragraph style. |
24 | * |
25 | * @see http://www.datypic.com/sc/ooxml/t-w_CT_Spacing.html |
26 | * @since 0.10.0 |
27 | */ |
28 | class Spacing extends AbstractStyle |
29 | { |
30 | /** |
31 | * Spacing above paragraph (twip). |
32 | * |
33 | * @var null|float|int |
34 | */ |
35 | private $before; |
36 | |
37 | /** |
38 | * Spacing below paragraph (twip). |
39 | * |
40 | * @var null|float|int |
41 | */ |
42 | private $after; |
43 | |
44 | /** |
45 | * Spacing between lines in paragraph (twip). |
46 | * |
47 | * @var null|float|int |
48 | */ |
49 | private $line; |
50 | |
51 | /** |
52 | * Type of spacing between lines. |
53 | * |
54 | * @var string |
55 | */ |
56 | private $lineRule = LineSpacingRule::AUTO; |
57 | |
58 | /** |
59 | * Create a new instance. |
60 | * |
61 | * @param array $style |
62 | */ |
63 | public function __construct($style = []) |
64 | { |
65 | $this->setStyleByArray($style); |
66 | } |
67 | |
68 | /** |
69 | * Get before. |
70 | * |
71 | * @return null|float|int |
72 | */ |
73 | public function getBefore() |
74 | { |
75 | return $this->before; |
76 | } |
77 | |
78 | /** |
79 | * Set before. |
80 | * |
81 | * @param null|float|int $value |
82 | * |
83 | * @return self |
84 | */ |
85 | public function setBefore($value = null) |
86 | { |
87 | $this->before = $this->setNumericVal($value, $this->before); |
88 | |
89 | return $this; |
90 | } |
91 | |
92 | /** |
93 | * Get after. |
94 | * |
95 | * @return null|float|int |
96 | */ |
97 | public function getAfter() |
98 | { |
99 | return $this->after; |
100 | } |
101 | |
102 | /** |
103 | * Set after. |
104 | * |
105 | * @param null|float|int $value |
106 | * |
107 | * @return self |
108 | */ |
109 | public function setAfter($value = null) |
110 | { |
111 | $this->after = $this->setNumericVal($value, $this->after); |
112 | |
113 | return $this; |
114 | } |
115 | |
116 | /** |
117 | * Get line. |
118 | * |
119 | * @return null|float|int |
120 | */ |
121 | public function getLine() |
122 | { |
123 | return $this->line; |
124 | } |
125 | |
126 | /** |
127 | * Set distance. |
128 | * |
129 | * @param null|float|int $value |
130 | * |
131 | * @return self |
132 | */ |
133 | public function setLine($value = null) |
134 | { |
135 | $this->line = $this->setNumericVal($value, $this->line); |
136 | |
137 | return $this; |
138 | } |
139 | |
140 | /** |
141 | * Get line rule. |
142 | * |
143 | * @return string |
144 | */ |
145 | public function getLineRule() |
146 | { |
147 | return $this->lineRule; |
148 | } |
149 | |
150 | /** |
151 | * Set line rule. |
152 | * |
153 | * @param string $value |
154 | * |
155 | * @return self |
156 | */ |
157 | public function setLineRule($value = null) |
158 | { |
159 | LineSpacingRule::validate($value); |
160 | $this->lineRule = $value; |
161 | |
162 | return $this; |
163 | } |
164 | } |