Redaxscript\Validator\Captcha::validate PHP Method

validate() public method

validate the captcha
Since: 2.2.0
public validate ( string $task = null, string $hash = null ) : integer
$task string plain task
$hash string hashed solution
return integer
    public function validate($task = null, $hash = null)
    {
        $output = ValidatorInterface::FAILED;
        $captchaHash = new Hash(Config::getInstance());
        /* validate captcha */
        if ($task && $captchaHash->validate($task, $hash)) {
            $output = ValidatorInterface::PASSED;
        }
        return $output;
    }

Usage Example

示例#1
0
 /**
  * testCaptcha
  *
  * @since 2.2.0
  *
  * @param string $raw
  * @param string $hash
  * @param integer $expect
  *
  * @dataProvider providerValidatorCaptcha
  */
 public function testCaptcha($raw = null, $hash = null, $expect = null)
 {
     /* setup */
     $validator = new Validator\Captcha();
     /* result */
     $result = $validator->validate($raw, $hash);
     /* compare */
     $this->assertEquals($expect, $result);
 }
All Usage Examples Of Redaxscript\Validator\Captcha::validate
Captcha