PHP Class Vimeo\ABLincoln\Namespaces\SimpleNamespace

Inheritance: extends AbstractNamespace
Mostra file Open project: vimeo/ablincoln

Protected Properties

Property Type Description
$inputs
$name
$num_segments
$primary_unit

Public Methods

Method Description
__construct ( array $inputs ) Set up attributes needed for the namespace
addExperiment ( string $name, string $exp_class, integer $num_segments ) Map a new experiment to a given number of segments in the namespace
get ( string $name, string $default = null ) : the Get the value of a given experiment parameter - triggers exposure log
inExperiment ( ) : boolean In-experiment accessor
logEvent ( $event_type, array $extras = null ) Log an arbitrary event
logExposure ( array $extras = null ) Logs exposure to treatment
primaryUnit ( ) : array Get the primary unit that will be mapped to segments
removeExperiment ( string $name ) Remove a given experiment from the namespace and free its associated segments
setAutoExposureLogging ( boolean $value ) Disables / enables auto exposure logging (enabled by default)
setPrimaryUnit ( mixed $value ) Set the primary unit that will be used to map to segments
setup ( ) Set namespace attributes for run. Developers extending this class should set the following variables: this->name = 'sample namespace'; this->primary_unit = 'userid'; this->num_segments = 10000;
setupExperiments ( ) Setup experiments segments will be assigned to: $this->addExperiment('first experiment', Exp1, 100);

Protected Methods

Method Description
_requiresDefaultExperiment ( ) Checks if primary unit segment is assigned to a default experiment, and if not assigns it to one
_requiresExperiment ( ) Checks if primary unit segment is assigned to an experiment, and if not assigns it to one

Private Methods

Method Description
_assignDefaultExperiment ( ) Assigns the primary unit value(s) and associated segment to a new default experiment used if segment not assigned to a real one
_assignExperiment ( ) Assigns the primary unit value(s) and associated segment to a new experiment and updates the experiment name/salt accordingly
_defaultGet ( string $name, string $default = null ) : the Get the value of a given default experiment parameter. Called on get() if primary unit value(s) not mapped to a real experiment
_getSegment ( ) : integer Use the primary unit value(s) to obtain a segment and associated experiment

Method Details

__construct() public method

Set up attributes needed for the namespace
public __construct ( array $inputs )
$inputs array data to determine parameter assignments, e.g. userid

_requiresDefaultExperiment() protected method

Checks if primary unit segment is assigned to a default experiment, and if not assigns it to one

_requiresExperiment() protected method

Checks if primary unit segment is assigned to an experiment, and if not assigns it to one
protected _requiresExperiment ( )

addExperiment() public method

Map a new experiment to a given number of segments in the namespace
public addExperiment ( string $name, string $exp_class, integer $num_segments )
$name string name to give the new experiment
$exp_class string string version of experiment class to instantiate
$num_segments integer number of segments to allocate to experiment

get() public method

Get the value of a given experiment parameter - triggers exposure log
public get ( string $name, string $default = null ) : the
$name string parameter to get the value of
$default string optional value to return if parameter undefined
return the value of the given parameter

inExperiment() public method

In-experiment accessor
public inExperiment ( ) : boolean
return boolean true if primary unit mapped to an experiment, false otherwise

logEvent() public method

Log an arbitrary event
public logEvent ( $event_type, array $extras = null )
$extras array optional extra data to include in log

logExposure() public method

Logs exposure to treatment
public logExposure ( array $extras = null )
$extras array optional extra data to include in exposure log

primaryUnit() public method

Get the primary unit that will be mapped to segments
public primaryUnit ( ) : array
return array array containing value(s) used for unit assignment

removeExperiment() public method

Remove a given experiment from the namespace and free its associated segments
public removeExperiment ( string $name )
$name string previously defined name of experiment to remove

setAutoExposureLogging() public method

Disables / enables auto exposure logging (enabled by default)
public setAutoExposureLogging ( boolean $value )
$value boolean true to enable, false to disable

setPrimaryUnit() public method

Set the primary unit that will be used to map to segments
public setPrimaryUnit ( mixed $value )
$value mixed value or array used for unit assignment to segments

setup() abstract public method

Set namespace attributes for run. Developers extending this class should set the following variables: this->name = 'sample namespace'; this->primary_unit = 'userid'; this->num_segments = 10000;
abstract public setup ( )

setupExperiments() abstract public method

Setup experiments segments will be assigned to: $this->addExperiment('first experiment', Exp1, 100);
abstract public setupExperiments ( )

Property Details

$inputs protected_oe property

protected $inputs

$name protected_oe property

protected $name

$num_segments protected_oe property

protected $num_segments

$primary_unit protected_oe property

protected $primary_unit