Merge pull request #2574 from dhensby/patch-1

Allowing chaining on `PasswordValidator`
This commit is contained in:
Sean Harvey 2013-10-31 15:54:18 -07:00
commit 42fa4d6005

View File

@ -16,7 +16,7 @@
* @subpackage security
*/
class PasswordValidator extends Object {
private static $character_strength_tests = array(
'lowercase' => '/[a-z]/',
'uppercase' => '/[A-Z]/',
@ -31,6 +31,7 @@ class PasswordValidator extends Object {
*/
public function minLength($minLength) {
$this->minLength = $minLength;
return $this;
}
/**
@ -44,6 +45,7 @@ class PasswordValidator extends Object {
public function characterStrength($minScore, $testNames) {
$this->minScore = $minScore;
$this->testNames = $testNames;
return $this;
}
/**
@ -51,6 +53,7 @@ class PasswordValidator extends Object {
*/
public function checkHistoricalPasswords($count) {
$this->historicalPasswordCount = $count;
return $this;
}
/**
@ -59,7 +62,7 @@ class PasswordValidator extends Object {
* @return ValidationResult
*/
public function validate($password, $member) {
$valid = new ValidationResult();
$valid = ValidationResult::create();
if($this->minLength) {
if(strlen($password) < $this->minLength) {