Text_CAPTCHA_Numeral
[ class tree: Text_CAPTCHA_Numeral ] [ index: Text_CAPTCHA_Numeral ] [ all elements ]

Class: Text_CAPTCHA_Numeral

Source Location: /Text_CAPTCHA_Numeral-1.3.2/Text/CAPTCHA/Numeral.php

Class Overview


Class used for numeral captchas


Author(s):

Copyright:

  • 2002-2007 Agora Production (http://agoraproduction.com)

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 34]
Class used for numeral captchas

This class is intended to be used to generate numeral captchas as such as: Example: Give me the answer to "54 + 2" to prove that you are human.



[ Top ]


Class Variables

$answer =

[line 119]

The operation answer

The answer to the numeral operation we are about to do.

  • Var: The mathematical operation answer value.
  • Access: protected

Type:   integer


[ Top ]

$firstNumber =  ''

[line 98]

First number of the operation

This variable holds the first number of the numeral operation we are about to generate.

  • Var: The first number of the operation
  • Access: protected

Type:   integer


[ Top ]

$maxValue =  '50'

[line 55]

Maximum range value

This variable holds the maximum range value default set to "50"

  • Var: The maximum value of the number range
  • Access: protected

Type:   integer


[ Top ]

$minValue =  '1'

[line 45]

Minimum range value

This variable holds the minimum range value default set to "1"

  • Var: The minimum range value
  • Access: protected

Type:   integer


[ Top ]

$operation =  ''

[line 87]

Mathematical Operation

This is the mathematical operation that we are displaying to the user.

  • Var: The math operation
  • Access: protected

Type:   string


[ Top ]

$operator =  ''

[line 77]

Operator to use

This variable is basically the operation that we're going to be using in the numeral captcha we are about to generate.

  • Var: The operation's operator
  • Access: protected

Type:   string


[ Top ]

$operators = array('+','-')

[line 66]

Operators

The valid operators to use in the numeral captcha. We could use / and * but not yet.

  • Var: The operations for the captcha
  • Access: protected

Type:   array


[ Top ]

$secondNumber =  ''

[line 109]

Second Number of the operation

This variable holds the value of the second variable of the operation we are about to generate for the captcha.

  • Var: The second number of the operation
  • Access: protected

Type:   integer


[ Top ]



Method Detail

__construct (Constructor)   [line 178]

Text_CAPTCHA_Numeral __construct( [constant $complexityType = self::COMPLEXITY_ELEMENTARY], [integer $minValue = 1], [integer $maxValue = 50])

Constructor with different levels of mathematical operations sets
  • Access: public

Parameters:

constant   $complexityType   —  How complex the captcha equation shall be. See the COMPLEXITY constants.
integer   $minValue   —  Minimal value of a number
integer   $maxValue   —  Maximal value of a number

[ Top ]

calculateFactorial   [line 522]

integer calculateFactorial( integer $n)

Calculate factorial given an integer number
  • Return: The calculated value
  • Access: protected

Parameters:

integer   $n   —  The factorial to calculate

[ Top ]

doAdd   [line 358]

void doAdd( )

Adds values

This function will add the firstNumber and the secondNumber value and then call setAnswer to set the answer value.

  • See: $this->firstNumber, $this->secondNumber, $this->setAnswer()
  • Access: protected

[ Top ]

doDivision   [line 393]

void doDivision( [integer $firstNumber = null], [integer $secondNumber = null])

Do Division

This function executes a division based on the two numbers.

  • Access: protected

Parameters:

integer   $firstNumber   —  The first number of the operation. This is by default set to null.
integer   $secondNumber   —  The second number of the operation This is by default set to null.

[ Top ]

doExponentiation   [line 496]

void doExponentiation( )

Does an exponentiation on the values

This function executes an exponentiation

  • See: $this->setOperation, $this->getFirstNumber $this->getSecondNumber, $this->setAnswer()
  • Access: protected

[ Top ]

doFactorial   [line 508]

void doFactorial( )

Call static factorial method
  • Access: protected

[ Top ]

doModulus   [line 438]

void doModulus( )

Do modulus

This method will do a modulus operation between two numbers

  • See: $this->firstNumber, $this->secondNumber, $this->setAnswer()
  • Access: protected

[ Top ]

doMultiplication   [line 374]

void doMultiplication( )

Do Multiplication

This method will multiply two numbers

  • See: $this->firstNumber, $this->secondNumber, $this->setAnswer
  • Access: protected

[ Top ]

doSubstract   [line 467]

void doSubstract( )

Does a substract on the values

This function executes a substraction on the firstNumber and the secondNumber to then call $this->setAnswer to set the answer value.

If the firstnumber value is smaller than the secondnumber value then we regenerate the first number and regenerate the operation.

  • See: $this->firstNumber, $this->secondNumber, $this->setAnswer()
  • Access: protected

[ Top ]

generateFirstNumber   [line 214]

void generateFirstNumber( )

Sets the first number

This function sets the first number of the operation by calling the generateNumber function that generates a random number.

  • See: $this->firstNumber, $this->generateNumber
  • Access: protected

[ Top ]

generateNumber   [line 341]

integer generateNumber( )

Generate a number

This function takes the parameters that are in the $this->maxValue and $this->minValue and get the random number from them using mt_rand()

  • Return: Random value between minValue and maxValue
  • Access: protected

[ Top ]

generateOperation   [line 540]

void generateOperation( )

Generate the operation

This function will call the setOperation() function to set the operation string that will be called to display the operation, and call the function necessary depending on which operation is set by this->operator.

  • See: $this->setOperation(), $this->operator
  • Access: protected

[ Top ]

generateOperator   [line 247]

void generateOperator( )

Sets the operation operator

This function sets the operation operator by getting the array value of an array_rand() of the $this->operators() array.

  • See: $this->operators, $this->operator
  • Access: protected

[ Top ]

generateSecondNumber   [line 230]

void generateSecondNumber( )

Sets second number

This function sets the second number of the operation by calling generateNumber()

  • See: $this->secondNumber, $this->generateNumber()
  • Access: protected

[ Top ]

getAnswer   [line 600]

string getAnswer( )

Get the answer value

This function will retrieve the answer value from this->answer and return it so we can then display it to the user.

  • Return: The operation answer value.
  • Access: public

[ Top ]

getFirstNumber   [line 614]

integer getFirstNumber( )

Get the first number

This function will get the first number value from $this->firstNumber

  • Return: The firstNumber
  • Access: public

[ Top ]

getOperation   [line 585]

string getOperation( )

Get operation

This function will get the operation string from $this->operation

  • Return: The operation String
  • Access: public

[ Top ]

getSecondNumber   [line 627]

integer getSecondNumber( )

Get the second number value

This function will return the second number value

  • Return: The second number
  • Access: public

[ Top ]

prepare   [line 646]

void prepare( constant $complexityType, integer $minValue, integer $maxValue)

prepare class with the values

This function prepare configure the values to generate the captcha

  • Access: public

Parameters:

constant   $complexityType   —  How complex the captcha equation shall be. See the COMPLEXITY constants.
integer   $minValue   —  Minimal value of a number
integer   $maxValue   —  Maximal value of a number

[ Top ]

setAnswer   [line 266]

void setAnswer( integer $answerValue)

Sets the answer value

This function will accept the parameters which is basically the result of the function we have done and it will set $this->answer with it.

  • See: $this->answer
  • Access: protected

Parameters:

integer   $answerValue   —  The answer value

[ Top ]

setFirstNumber   [line 283]

Text_CAPTCHA_Numeral setFirstNumber( integer $value)

Set First number

This function sets the first number to the value passed to the function

  • Return: The self object
  • Access: protected

Parameters:

integer   $value   —  The first number value.

[ Top ]

setOperation   [line 319]

void setOperation( [string $type = null])

Set "operation" string the user needs to solve.

This variable sets the operation variable by taking the firstNumber, secondNumber and operator

  • See: $this->operation
  • Access: protected

Parameters:

string   $type   —  May be null, or "F" to indicate a factorial operation

[ Top ]

setRangeMinimum   [line 197]

void setRangeMinimum( [integer $minValue = '1'])

Set Range Minimum value

This function give the developer the ability to set the range minimum value so the operations can be bigger, smaller, etc.

  • Access: protected

Parameters:

integer   $minValue   —  The minimum value

[ Top ]

setSecondNumber   [line 300]

Text_CAPTCHA_Numeral setSecondNumber( integer $value)

Sets the second number

This function sets the second number with the value passed to it.

  • Return: The self object
  • Access: protected

Parameters:

integer   $value   —  The second number new value.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:56:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.