Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
18 / 18 |
|
100.00% |
11 / 11 |
CRAP | |
100.00% |
1 / 1 |
FormField | |
100.00% |
18 / 18 |
|
100.00% |
11 / 11 |
11 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setType | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getDefault | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDefault | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setValue | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getEntries | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setEntries | |
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\Element; |
19 | |
20 | /** |
21 | * Form field element. |
22 | * |
23 | * @since 0.12.0 |
24 | * @see http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html |
25 | */ |
26 | class FormField extends Text |
27 | { |
28 | /** |
29 | * Form field type: textinput|checkbox|dropdown. |
30 | * |
31 | * @var string |
32 | */ |
33 | private $type = 'textinput'; |
34 | |
35 | /** |
36 | * Form field name. |
37 | * |
38 | * @var ?string |
39 | */ |
40 | private $name; |
41 | |
42 | /** |
43 | * Default value. |
44 | * |
45 | * - TextInput: string |
46 | * - CheckBox: bool |
47 | * - DropDown: int Index of entries (zero based) |
48 | * |
49 | * @var bool|int|string |
50 | */ |
51 | private $default; |
52 | |
53 | /** |
54 | * Value. |
55 | * |
56 | * @var null|bool|int|string |
57 | */ |
58 | private $value; |
59 | |
60 | /** |
61 | * Dropdown entries. |
62 | * |
63 | * @var array |
64 | */ |
65 | private $entries = []; |
66 | |
67 | /** |
68 | * Create new instance. |
69 | * |
70 | * @param string $type |
71 | * @param mixed $fontStyle |
72 | * @param mixed $paragraphStyle |
73 | */ |
74 | public function __construct($type, $fontStyle = null, $paragraphStyle = null) |
75 | { |
76 | parent::__construct(null, $fontStyle, $paragraphStyle); |
77 | $this->setType($type); |
78 | } |
79 | |
80 | /** |
81 | * Get type. |
82 | * |
83 | * @return string |
84 | */ |
85 | public function getType() |
86 | { |
87 | return $this->type; |
88 | } |
89 | |
90 | /** |
91 | * Set type. |
92 | * |
93 | * @param string $value |
94 | * |
95 | * @return self |
96 | */ |
97 | public function setType($value) |
98 | { |
99 | $enum = ['textinput', 'checkbox', 'dropdown']; |
100 | $this->type = $this->setEnumVal($value, $enum, $this->type); |
101 | |
102 | return $this; |
103 | } |
104 | |
105 | /** |
106 | * Get name. |
107 | * |
108 | * @return ?string |
109 | */ |
110 | public function getName() |
111 | { |
112 | return $this->name; |
113 | } |
114 | |
115 | /** |
116 | * Set name. |
117 | * |
118 | * @param ?string $value |
119 | * |
120 | * @return self |
121 | */ |
122 | public function setName($value) |
123 | { |
124 | $this->name = $value; |
125 | |
126 | return $this; |
127 | } |
128 | |
129 | /** |
130 | * Get default. |
131 | * |
132 | * @return bool|int|string |
133 | */ |
134 | public function getDefault() |
135 | { |
136 | return $this->default; |
137 | } |
138 | |
139 | /** |
140 | * Set default. |
141 | * |
142 | * @param bool|int|string $value |
143 | * |
144 | * @return self |
145 | */ |
146 | public function setDefault($value) |
147 | { |
148 | $this->default = $value; |
149 | |
150 | return $this; |
151 | } |
152 | |
153 | /** |
154 | * Get value. |
155 | * |
156 | * @return null|bool|int|string |
157 | */ |
158 | public function getValue() |
159 | { |
160 | return $this->value; |
161 | } |
162 | |
163 | /** |
164 | * Set value. |
165 | * |
166 | * @param null|bool|int|string $value |
167 | * |
168 | * @return self |
169 | */ |
170 | public function setValue($value) |
171 | { |
172 | $this->value = $value; |
173 | |
174 | return $this; |
175 | } |
176 | |
177 | /** |
178 | * Get entries. |
179 | * |
180 | * @return array |
181 | */ |
182 | public function getEntries() |
183 | { |
184 | return $this->entries; |
185 | } |
186 | |
187 | /** |
188 | * Set entries. |
189 | * |
190 | * @param array $value |
191 | * |
192 | * @return self |
193 | */ |
194 | public function setEntries($value) |
195 | { |
196 | $this->entries = $value; |
197 | |
198 | return $this; |
199 | } |
200 | } |