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