PHP Class Vimeo\ABLincoln\Experiments\AbstractExperiment

Mostra file Open project: vimeo/ablincoln

Protected Properties

Property Type Description
$assignment
$in_experiment
$inputs
$logger_configured
$name
$salt

Public Methods

Method Description
__construct ( mixed $inputs ) Set up attributes needed for experiment
__toString ( ) : string JSON representation of exposure log data - triggers exposure log
assign ( Assignment $params, array $inputs ) Add parameters used in experiment to current assignment
exposureLogged ( ) : boolean See whether the experiment has already been exposure logged
get ( string $name, string $default = null ) : the Get the value of a given experiment parameter - triggers exposure log
getParams ( ) : array Get all experiment parameters - triggers exposure log. In general, this should only be used by custom loggers
inExperiment ( ) : boolean In-experiment accessor
logEvent ( string $eventType, array $extras = null ) Log an arbitrary event
logExposure ( array $extras = null ) Logs exposure to treatment
name ( ) : string Experiment name accessor
salt ( ) : string Experiment-level salt accessor
setAutoExposureLogging ( boolean $value ) Disables / enables auto exposure logging (enabled by default)
setExposureLogged ( boolean $value ) Set whether the experiment has been exposure logged
setInExperiment ( boolean $value ) In-experiment setter
setName ( string $value ) Experiment name setter
setOverrides ( array $overrides ) Sets variables that are to remain fixed during execution. Note that setting this will overwrite inputs to the experiment
setSalt ( string $value ) Experiment-level salt setter
setup ( ) * Optionally set experiment attributes before run, e.g. name and salt

Protected Methods

Method Description
_asBlob ( array $extras = [] ) : array Get an array representation of the experiment data
_configureLogger ( ) Set up files, database connections, sockets, etc for logging
_log ( array $data ) Log experiment data
_previouslyLogged ( ) : boolean Check if the input has already been logged. Gets called once in the constructor
_requiresExposureLogging ( ) Checks if experiment requires exposure logging, and if so exposure logs

Private Methods

Method Description
_assignSetup ( ) Assignment and setup that happens when we need to log data
_requiresAssignment ( ) Checks if an assignment has been made, assigns one if not

Method Details

__construct() public method

Set up attributes needed for experiment
public __construct ( mixed $inputs )
$inputs mixed input value or array to determine parameter assignments, e.g. userid

__toString() public method

JSON representation of exposure log data - triggers exposure log
public __toString ( ) : string
return string JSON representation of exposure log data

_asBlob() protected method

Get an array representation of the experiment data
protected _asBlob ( array $extras = [] ) : array
$extras array extra data to include in array
return array experiment data

_configureLogger() abstract protected method

Set up files, database connections, sockets, etc for logging
abstract protected _configureLogger ( )

_log() abstract protected method

Log experiment data
abstract protected _log ( array $data )
$data array data to log

_previouslyLogged() abstract protected method

Check if the input has already been logged. Gets called once in the constructor
abstract protected _previouslyLogged ( ) : boolean
return boolean true if previously logged, false otherwise

_requiresExposureLogging() protected method

Checks if experiment requires exposure logging, and if so exposure logs
protected _requiresExposureLogging ( )

assign() abstract public method

Add parameters used in experiment to current assignment
abstract public assign ( Assignment $params, array $inputs )
$params Vimeo\ABLincoln\Assignment assignment in which to place new parameters
$inputs array input data to determine parameter assignments

exposureLogged() public method

See whether the experiment has already been exposure logged
public exposureLogged ( ) : boolean
return boolean true if exposure logged, false otherwise

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

getParams() public method

Get all experiment parameters - triggers exposure log. In general, this should only be used by custom loggers
public getParams ( ) : array
return array experiment parameters

inExperiment() public method

In-experiment accessor
public inExperiment ( ) : boolean
return boolean true if currently in experiment, false otherwise

logEvent() public method

Log an arbitrary event
public logEvent ( string $eventType, array $extras = null )
$eventType string name of event to log
$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

name() public method

Experiment name accessor
public name ( ) : string
return string the experiment name

salt() public method

Experiment-level salt accessor
public salt ( ) : string
return string the experiment-level salt

setAutoExposureLogging() public method

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

setExposureLogged() public method

Set whether the experiment has been exposure logged
public setExposureLogged ( boolean $value )
$value boolean true if exposure logged, false otherwise

setInExperiment() public method

In-experiment setter
public setInExperiment ( boolean $value )
$value boolean true if currently in experiment, false otherwise

setName() public method

Experiment name setter
public setName ( string $value )
$value string value to set the experiment name

setOverrides() public method

Sets variables that are to remain fixed during execution. Note that setting this will overwrite inputs to the experiment
public setOverrides ( array $overrides )
$overrides array parameter name/value pairs to use as overrides

setSalt() public method

Experiment-level salt setter
public setSalt ( string $value )
$value string value to set the experiment-level salt

setup() public method

* Optionally set experiment attributes before run, e.g. name and salt
public setup ( )

Property Details

$assignment protected_oe property

protected $assignment

$in_experiment protected_oe property

protected $in_experiment

$inputs protected_oe property

protected $inputs

$logger_configured protected_oe property

protected $logger_configured

$name protected_oe property

protected $name

$salt protected_oe property

protected $salt