Field_Email::getInput()   B
last analyzed

Complexity

Conditions 7
Paths 64

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 7
nc 64
nop 0
dl 15
loc 15
rs 8.8333
c 0
b 0
f 0
1
<?php
2
/**
3
 * Part of the Joomla Framework Form Package
4
 *
5
 * @copyright  Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
6
 * @license    GNU General Public License version 2 or later; see LICENSE
7
 */
8
9
namespace Joomla\Form;
10
11
/**
12
 * Form Field class for the Joomla Framework.
13
 * Provides and input field for e-mail addresses
14
 *
15
 * @link        http://www.w3.org/TR/html-markup/input.email.html#input.email
16
 * @see         JFormRuleEmail
17
 * @since       1.0
18
 * @deprecated  The joomla/form package is deprecated
19
 */
20 View Code Duplication
class Field_Email extends Field
0 ignored issues
show
Deprecated Code introduced by
The class Joomla\Form\Field has been deprecated with message: The joomla/form package is deprecated

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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