Field_Password::getInput()   B
last analyzed

Complexity

Conditions 7
Paths 64

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
nc 64
nop 0
dl 0
loc 16
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
 * Text field for passwords
14
 *
15
 * @link        http://www.w3.org/TR/html-markup/input.password.html#input.password
16
 * @note        Two password fields may be validated as matching using JFormRuleEquals
17
 * @since       1.0
18
 * @deprecated  The joomla/form package is deprecated
19
 */
20
class Field_Password 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...
21
{
22
	/**
23
	 * The form field type.
24
	 *
25
	 * @var    string
26
	 * @since  1.0
27
	 */
28
	protected $type = 'Password';
29
30
	/**
31
	 * Method to get the field input markup for password.
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
		$auto		= ((string) $this->element['autocomplete'] == 'off') ? ' autocomplete="off"' : '';
44
		$readonly	= ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
45
		$disabled	= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
46
47
		$script = '';
48
49
		return '<input type="password" name="' . $this->name . '" id="' . $this->id . '"' .
50
			' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' .
51
			$auto . $class . $readonly . $disabled . $size . $maxLength . '/>' . $script;
52
	}
53
}
54