if (!
$constraint instanceof PasswordStrength
) { throw new UnexpectedTypeException($constraint, PasswordStrength::
class);
} if (null ===
$value) { return;
} if (!\
is_string($value)) { throw new UnexpectedValueException($value, 'string'
);
} $passwordStrengthEstimator =
$this->passwordStrengthEstimator ?? self::
estimateStrength(...
);
$strength =
$passwordStrengthEstimator($value);
if ($strength <
$constraint->minScore
) { $this->context->
buildViolation($constraint->message
) ->
setCode(PasswordStrength::PASSWORD_STRENGTH_ERROR
) ->
addViolation();
} } /**
* Returns the estimated strength of a password.
*
* The higher the value, the stronger the password.
*
* @return PasswordStrength::STRENGTH_*
*/