Hackzilla\PasswordGenerator\Generator\RequirementPasswordGenerator::validatePassword PHP Method

validatePassword() public method

Check password is valid when comparing to minimum and maximum counts of options.
public validatePassword ( string $password ) : boolean
$password string
return boolean
    public function validatePassword($password)
    {
        foreach ($this->validOptions as $option) {
            $minCount = $this->getMinimumCount($option);
            $maxCount = $this->getMaximumCount($option);
            $count = strlen(preg_replace('|[^' . preg_quote($this->getParameter($option)) . ']|', '', $password));
            if (!is_null($minCount) && $count < $minCount) {
                return false;
            }
            if (!is_null($maxCount) && $count > $maxCount) {
                return false;
            }
        }
        return true;
    }