Code Duplication    Length = 13-14 lines in 2 locations

forms/CheckboxSetField.php 1 location

@@ 238-251 (lines=14) @@
235
	 *
236
	 * @return string
237
	 */
238
	public function dataValue() {
239
		if($this->value && is_array($this->value)) {
240
			$filtered = array();
241
			foreach($this->value as $item) {
242
				if($item) {
243
					$filtered[] = str_replace(",", "{comma}", $item);
244
				}
245
			}
246
247
			return implode(',', $filtered);
248
		}
249
250
		return '';
251
	}
252
253
	public function performDisabledTransformation() {
254
		$clone = clone $this;

forms/ListboxField.php 1 location

@@ 156-168 (lines=13) @@
153
	 *
154
	 * @return string
155
	 */
156
	public function dataValue() {
157
		if($this->value && is_array($this->value) && $this->multiple) {
158
			$filtered = array();
159
			foreach($this->value as $item) {
160
				if($item) {
161
					$filtered[] = str_replace(",", "{comma}", $item);
162
				}
163
			}
164
			return implode(',', $filtered);
165
		} else {
166
			return parent::dataValue();
167
		}
168
	}
169
170
	/**
171
	 * Save the current value of this field into a DataObject.