Пример #1
0
function captcha($pattern, $left, $operator, $right)
{
    if ($pattern < 1 or $pattern > 2 or ($operator < 1 or $operator > 3)) {
        return "You shouldn't do this to me :(" . "\n";
    }
    $captcha = new Captcha($pattern, $left, $operator, $right);
    return $captcha->toString();
}
 function buildCaptcha()
 {
     $pattern = $this->randomizer->pattern();
     $left = $this->randomizer->operand();
     $operator = $this->randomizer->operator();
     $right = $this->randomizer->operand();
     $captcha = new Captcha($pattern, $left, $operator, $right);
     return $captcha->toString();
 }
Пример #3
0
                                    }
                                }
                            }
                        }
                    }
                }
                if ($operator == 1) {
                    $this->result = $this->result . "+";
                } else {
                    if ($operator == 2) {
                        $this->result = $this->result . "-";
                    } else {
                        if ($operator == 3) {
                            $this->result == $this->result . "x";
                        }
                    }
                }
                $this->result = $this->result . $leftOperand;
            }
        }
    }
    function toString()
    {
        echo $this->result . "\n";
    }
}
$cap1 = new Captcha(1, 2, 1, 9);
$cap1->toString();
$cap2 = new Captcha(2, 2, 1, 9);
$cap2->toString();
Пример #4
0
 function testCaptcha2111ShouldBe1PlusOne()
 {
     $captcha = new Captcha(2, 1, 1, 1);
     $this->assertEquals("1 + One", $captcha->toString());
 }
Пример #5
0
 function testResultCaptchaWhenLeftOperandIsInteger()
 {
     $captcha = new Captcha(2, 1, 2, 1);
     $result = $captcha->toString();
     $this->assertEquals("1 * One", $result);
 }