Allowing chaining on PasswordValidator

Allowing chaining on `PasswordValidator`.

Also using injector pattern for `ValidationResult` instanciation
This commit is contained in:
Daniel Hensby 2013-10-21 18:10:37 +01:00 committed by Daniel Hensby
parent 9b23e8c6c3
commit 974d575826

View File

@ -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) {