PHP Класс Namshi\AB\Test

Наследование: implements Countabl\Countable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$hasRun
$isEnabled
$name
$parameters
$seed
$variation
$variations

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
calculateVariation ( ) Calculates the variation of this test.
validateVariations ( array $variations ) Validates an array of variations.

Описание методов

__construct() публичный Метод

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() защищенный Метод

Calculates the variation of this test.
protected calculateVariation ( )

count() публичный Метод

Returns how many variations the test contains.
public count ( ) : integer
Результат integer

disable() публичный Метод

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() публичный Метод

Returns a test's parameter.
public get ( string $parameter ) : mixed
$parameter string
Результат mixed

getName() публичный Метод

Returns the name of the test.
public getName ( ) : string
Результат string

getParameters() публичный Метод

Gets the parameters for this test.
public getParameters ( ) : array
Результат array

getSeed() публичный Метод

Gets the seed for this test.
public getSeed ( ) : integer
Результат integer

getVariation() публичный Метод

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
Результат string

getVariations() публичный Метод

Returns the variations of this test.
public getVariations ( ) : array
Результат array

hasRun() публичный Метод

Checks whether the test has run or not.
public hasRun ( boolean $ran = null ) : boolean
$ran boolean
Результат boolean

isDisabled() публичный Метод

Checks whether the test is disabled or not.
public isDisabled ( ) : boolean
Результат boolean

isEnabled() публичный Метод

Checks whether the test is enabled or not.
public isEnabled ( ) : boolean
Результат boolean

run() публичный Метод

Runs the test.
public run ( )

set() публичный Метод

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

setName() публичный Метод

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

setParameters() публичный Метод

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

setSeed() публичный Метод

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

setVariations() публичный Метод

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

validateVariations() защищенный Метод

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

Описание свойств

$hasRun защищенное свойство

protected $hasRun

$isEnabled защищенное свойство

protected $isEnabled

$name защищенное свойство

protected $name

$parameters защищенное свойство

protected $parameters

$seed защищенное свойство

protected $seed

$variation защищенное свойство

protected $variation

$variations защищенное свойство

protected $variations