PHP Class Namshi\AB\Test

Inheritance: implements Countabl\Countable
Datei anzeigen Open project: namshi/ab Class Usage Examples

Protected Properties

Property Type Description
$hasRun
$isEnabled
$name
$parameters
$seed
$variation
$variations

Public Methods

Method Description
__construct ( string $name, array $variations = [], array $parameters = [] ) Creates a test with the given $name and the specified $variations.
count ( ) : integer Returns how many variations the test contains.
disable ( ) Disables the test: this is useful when, for example, you want to exclude this test to run for specific request (for example, bots).
get ( string $parameter ) : mixed Returns a test's parameter.
getName ( ) : string Returns the name of the test.
getParameters ( ) : array Gets the parameters for this test.
getSeed ( ) : integer Gets the seed for this test.
getVariation ( ) : string Returns the variation of this test.
getVariations ( ) : array Returns the variations of this test.
hasRun ( boolean $ran = null ) : boolean Checks whether the test has run or not.
isDisabled ( ) : boolean Checks whether the test is disabled or not.
isEnabled ( ) : boolean Checks whether the test is enabled or not.
run ( ) Runs the test.
set ( string $parameter, mixed $value ) Returns a test's parameter.
setName ( string $name ) Sets the test's $name.
setParameters ( array $parameters ) Sets the parameters for this test.
setSeed ( integer $seed ) Sets the seed for this test.
setVariations ( array $variations ) Sets the $variations of this test.

Protected Methods

Method Description
calculateVariation ( ) Calculates the variation of this test.
validateVariations ( array $variations ) Validates an array of variations.

Method Details

__construct() public method

Variations must have an absolute value, not a percentage; for example, - a: 100 - b: 100 means that both variations have 50% of probability.
public __construct ( string $name, array $variations = [], array $parameters = [] )
$name string
$variations array
$parameters array

calculateVariation() protected method

Calculates the variation of this test.
protected calculateVariation ( )

count() public method

Returns how many variations the test contains.
public count ( ) : integer
return integer

disable() public method

Disables the test: this is useful when, for example, you want to exclude this test to run for specific request (for example, bots).
public disable ( )

get() public method

Returns a test's parameter.
public get ( string $parameter ) : mixed
$parameter string
return mixed

getName() public method

Returns the name of the test.
public getName ( ) : string
return string

getParameters() public method

Gets the parameters for this test.
public getParameters ( ) : array
return array

getSeed() public method

Gets the seed for this test.
public getSeed ( ) : integer
return integer

getVariation() public method

You must run the test before getting the variation, else a BadMethodCallException is thrown. If the test is disabled, the first variation will always be returned, even if its odd is set to 0.
public getVariation ( ) : string
return string

getVariations() public method

Returns the variations of this test.
public getVariations ( ) : array
return array

hasRun() public method

Checks whether the test has run or not.
public hasRun ( boolean $ran = null ) : boolean
$ran boolean
return boolean

isDisabled() public method

Checks whether the test is disabled or not.
public isDisabled ( ) : boolean
return boolean

isEnabled() public method

Checks whether the test is enabled or not.
public isEnabled ( ) : boolean
return boolean

run() public method

Runs the test.
public run ( )

set() public method

Returns a test's parameter.
public set ( string $parameter, mixed $value )
$parameter string
$value mixed

setName() public method

Sets the test's $name.
public setName ( string $name )
$name string

setParameters() public method

Sets the parameters for this test.
public setParameters ( array $parameters )
$parameters array

setSeed() public method

Sets the seed for this test.
public setSeed ( integer $seed )
$seed integer

setVariations() public method

Sets the $variations of this test.
public setVariations ( array $variations )
$variations array

validateVariations() protected method

All the variations must have an integer value.
protected validateVariations ( array $variations )
$variations array

Property Details

$hasRun protected_oe property

protected $hasRun

$isEnabled protected_oe property

protected $isEnabled

$name protected_oe property

protected $name

$parameters protected_oe property

protected $parameters

$seed protected_oe property

protected $seed

$variation protected_oe property

protected $variation

$variations protected_oe property

protected $variations