Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
28 / 28 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
FootnoteProperties | |
100.00% |
28 / 28 |
|
100.00% |
8 / 8 |
10 | |
100.00% |
1 / 1 |
getPos | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setPos | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |||
getNumFmt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setNumFmt | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getNumStart | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setNumStart | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getNumRestart | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setNumRestart | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
2 |
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\ComplexType; |
19 | |
20 | use InvalidArgumentException; |
21 | use PhpOffice\PhpWord\SimpleType\NumberFormat; |
22 | |
23 | /** |
24 | * Footnote properties. |
25 | * |
26 | * @see http://www.datypic.com/sc/ooxml/e-w_footnotePr-1.html |
27 | */ |
28 | final class FootnoteProperties |
29 | { |
30 | const RESTART_NUMBER_CONTINUOUS = 'continuous'; |
31 | const RESTART_NUMBER_EACH_SECTION = 'eachSect'; |
32 | const RESTART_NUMBER_EACH_PAGE = 'eachPage'; |
33 | |
34 | const POSITION_PAGE_BOTTOM = 'pageBottom'; |
35 | const POSITION_BENEATH_TEXT = 'beneathText'; |
36 | const POSITION_SECTION_END = 'sectEnd'; |
37 | const POSITION_DOC_END = 'docEnd'; |
38 | |
39 | /** |
40 | * Footnote Positioning Location. |
41 | * |
42 | * @var string |
43 | */ |
44 | private $pos; |
45 | |
46 | /** |
47 | * Footnote Numbering Format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat. |
48 | * |
49 | * @var string |
50 | */ |
51 | private $numFmt; |
52 | |
53 | /** |
54 | * Footnote and Endnote Numbering Starting Value. |
55 | * |
56 | * @var float |
57 | */ |
58 | private $numStart; |
59 | |
60 | /** |
61 | * Footnote and Endnote Numbering Restart Location. |
62 | * |
63 | * @var string |
64 | */ |
65 | private $numRestart; |
66 | |
67 | /** |
68 | * Get the Footnote Positioning Location. |
69 | * |
70 | * @return string |
71 | */ |
72 | public function getPos() |
73 | { |
74 | return $this->pos; |
75 | } |
76 | |
77 | /** |
78 | * Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd). |
79 | * |
80 | * @param string $pos |
81 | * |
82 | * @return self |
83 | */ |
84 | public function setPos($pos) |
85 | { |
86 | $position = [ |
87 | self::POSITION_PAGE_BOTTOM, |
88 | self::POSITION_BENEATH_TEXT, |
89 | self::POSITION_SECTION_END, |
90 | self::POSITION_DOC_END, |
91 | ]; |
92 | |
93 | if (in_array($pos, $position)) { |
94 | $this->pos = $pos; |
95 | } else { |
96 | throw new InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible'); |
97 | } |
98 | |
99 | return $this; |
100 | } |
101 | |
102 | /** |
103 | * Get the Footnote Numbering Format. |
104 | * |
105 | * @return string |
106 | */ |
107 | public function getNumFmt() |
108 | { |
109 | return $this->numFmt; |
110 | } |
111 | |
112 | /** |
113 | * Set the Footnote Numbering Format. |
114 | * |
115 | * @param string $numFmt One of NumberFormat |
116 | * |
117 | * @return self |
118 | */ |
119 | public function setNumFmt($numFmt) |
120 | { |
121 | NumberFormat::validate($numFmt); |
122 | $this->numFmt = $numFmt; |
123 | |
124 | return $this; |
125 | } |
126 | |
127 | /** |
128 | * Get the Footnote Numbering Format. |
129 | * |
130 | * @return float |
131 | */ |
132 | public function getNumStart() |
133 | { |
134 | return $this->numStart; |
135 | } |
136 | |
137 | /** |
138 | * Set the Footnote Numbering Format. |
139 | * |
140 | * @param float $numStart |
141 | * |
142 | * @return self |
143 | */ |
144 | public function setNumStart($numStart) |
145 | { |
146 | $this->numStart = $numStart; |
147 | |
148 | return $this; |
149 | } |
150 | |
151 | /** |
152 | * Get the Footnote and Endnote Numbering Starting Value. |
153 | * |
154 | * @return string |
155 | */ |
156 | public function getNumRestart() |
157 | { |
158 | return $this->numRestart; |
159 | } |
160 | |
161 | /** |
162 | * Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage). |
163 | * |
164 | * @param string $numRestart |
165 | * |
166 | * @return self |
167 | */ |
168 | public function setNumRestart($numRestart) |
169 | { |
170 | $restartNumbers = [ |
171 | self::RESTART_NUMBER_CONTINUOUS, |
172 | self::RESTART_NUMBER_EACH_SECTION, |
173 | self::RESTART_NUMBER_EACH_PAGE, |
174 | ]; |
175 | |
176 | if (in_array($numRestart, $restartNumbers)) { |
177 | $this->numRestart = $numRestart; |
178 | } else { |
179 | throw new InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible'); |
180 | } |
181 | |
182 | return $this; |
183 | } |
184 | } |