Code Duplication    Length = 10-10 lines in 3 locations

lib/PasswordValidator.php 3 locations

@@ 80-89 (lines=10) @@
77
	 * @param string $password
78
	 * @throws HintException
79
	 */
80
	public function checkUpperLowerCase($password) {
81
		$enforceUpperLowerCase= $this->config->getIsUpperLowerCaseEnforced();
82
		if($enforceUpperLowerCase === true && $this->hasUpperAndLowerCase($password) === false) {
83
			$message = 'Password should contain at least one upper and one lower case character.';
84
			$hint = $this->l->t(
85
				'Password should contain at least one upper and one lower case character.'
86
			);
87
			throw new HintException($message, $hint);
88
		}
89
	}
90
91
	/**
92
	 * validate the given password satisfies numeric character policy
@@ 97-106 (lines=10) @@
94
	 * @param string $password
95
	 * @throws HintException
96
	 */
97
	public function checkNumericCharacters($password) {
98
		$enforceNumericCharacters = $this->config->getIsNumericCharactersEnforced();
99
		if($enforceNumericCharacters === true && $this->hasNumericalCharacters($password) === false) {
100
			$message = 'Password should contain at least one numerical character.';
101
			$hint = $this->l->t(
102
				'Password should contain at least one numerical character.'
103
			);
104
			throw new HintException($message, $hint);
105
		}
106
	}
107
108
	/**
109
	 * check if password contains at least one special character
@@ 114-123 (lines=10) @@
111
	 * @param string $password
112
	 * @throws HintException
113
	 */
114
	public function checkSpecialCharacters($password) {
115
		$enforceSpecialCharacters = $this->config->getIsSpecialCharactersEnforced();
116
		if($enforceSpecialCharacters === true && $this->hasSpecialCharacter($password) === false) {
117
			$message = 'Password should contain at least one special character.';
118
			$hint = $this->l->t(
119
				'Password should contain at least one special character.'
120
			);
121
			throw new HintException($message, $hint);
122
		}
123
	}
124
125
	public function hasNumericalCharacters($password) {
126
		return preg_match('/\d/', $password) === 1 ? true : false;