Code Duplication    Length = 33-34 lines in 2 locations

Field/Email.php 1 location

@@ 20-52 (lines=33) @@
17
 * @since       1.0
18
 * @deprecated  The joomla/form package is deprecated
19
 */
20
class Field_Email extends Field
21
{
22
	/**
23
	 * The form field type.
24
	 *
25
	 * @var    string
26
	 * @since  1.0
27
	 */
28
	protected $type = 'Email';
29
30
	/**
31
	 * Method to get the field input markup for e-mail addresses.
32
	 *
33
	 * @return  string  The field input markup.
34
	 *
35
	 * @since   1.0
36
	 */
37
	protected function getInput()
38
	{
39
		// Initialize some field attributes.
40
		$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
41
		$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
42
		$class = $this->element['class'] ? ' ' . (string) $this->element['class'] : '';
43
		$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
44
		$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
45
46
		// Initialize JavaScript field attributes.
47
		$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
48
49
		return '<input type="text" name="' . $this->name . '" class="validate-email' . $class . '" id="' . $this->id . '"' . ' value="'
50
			. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $onchange . $maxLength . '/>';
51
	}
52
}
53

Field/Text.php 1 location

@@ 19-52 (lines=34) @@
16
 * @since       1.0
17
 * @deprecated  The joomla/form package is deprecated
18
 */
19
class Field_Text extends Field
20
{
21
	/**
22
	 * The form field type.
23
	 *
24
	 * @var    string
25
	 *
26
	 * @since  1.0
27
	 */
28
	protected $type = 'Text';
29
30
	/**
31
	 * Method to get the field input markup.
32
	 *
33
	 * @return  string  The field input markup.
34
	 *
35
	 * @since   1.0
36
	 */
37
	protected function getInput()
38
	{
39
		// Initialize some field attributes.
40
		$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
41
		$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
42
		$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
43
		$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
44
		$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
45
46
		// Initialize JavaScript field attributes.
47
		$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
48
49
		return '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="'
50
			. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size . $disabled . $readonly . $onchange . $maxLength . '/>';
51
	}
52
}
53