PHP Class Scientist\Experiment

An experiment allows us to implement our code in a new way without risking the introduction of bugs or regressions.
Afficher le fichier Open project: daylerees/scientist Class Usage Examples

Protected Properties

Свойство Type Description
$chance integer Execution chance.
$control callable The control callback.
$laboratory Laboratory Laboratory instance.
$matcher Scientist\Matchers\Matcher Matcher for experiment values.
$name string Experiment name.
$params array Parameters for our callbacks.
$trials array Trial callbacks.

Méthodes publiques

Méthode Description
__construct ( string $name, Laboratory $laboratory ) Create a new experiment.
chance ( integer $chance ) Set the execution chance.
control ( callable $callback ) Register a control callback.
getChance ( ) : integer Get the execution chance.
getControl ( ) : callable Fetch the control callback.
getLaboratory ( ) : Laboratory | null Retrieve the laboratory instance.
getMatcher ( ) : Scientist\Matchers\Matcher Get the matcher for this experiment.
getName ( ) : string Fetch the experiment name.
getParams ( ) : array Get the experiment parameters.
getTrial ( string $name ) : mixed Fetch a trial callback by name.
getTrials ( ) : array Fetch an array of trial callbacks.
matcher ( Scientist\Matchers\Matcher $matcher ) Set a matcher for this experiment.
report ( ) : Report Execute the experiment and return a report.
run ( ) : mixed Execute the experiment within the laboratory.
shouldRun ( ) : boolean Determine whether an experiment should run based on chance.
trial ( string $name, callable $callback ) Register a trial callback.

Method Details

__construct() public méthode

Create a new experiment.
public __construct ( string $name, Laboratory $laboratory )
$name string
$laboratory Laboratory

chance() public méthode

Set the execution chance.
public chance ( integer $chance )
$chance integer

control() public méthode

Register a control callback.
public control ( callable $callback )
$callback callable

getChance() public méthode

Get the execution chance.
public getChance ( ) : integer
Résultat integer

getControl() public méthode

Fetch the control callback.
public getControl ( ) : callable
Résultat callable

getLaboratory() public méthode

Retrieve the laboratory instance.
public getLaboratory ( ) : Laboratory | null
Résultat Laboratory | null

getMatcher() public méthode

Get the matcher for this experiment.
public getMatcher ( ) : Scientist\Matchers\Matcher
Résultat Scientist\Matchers\Matcher

getName() public méthode

Fetch the experiment name.
public getName ( ) : string
Résultat string

getParams() public méthode

Get the experiment parameters.
public getParams ( ) : array
Résultat array

getTrial() public méthode

Fetch a trial callback by name.
public getTrial ( string $name ) : mixed
$name string
Résultat mixed

getTrials() public méthode

Fetch an array of trial callbacks.
public getTrials ( ) : array
Résultat array

matcher() public méthode

Set a matcher for this experiment.
public matcher ( Scientist\Matchers\Matcher $matcher )
$matcher Scientist\Matchers\Matcher

report() public méthode

Execute the experiment and return a report.
public report ( ) : Report
Résultat Report

run() public méthode

Execute the experiment within the laboratory.
public run ( ) : mixed
Résultat mixed

shouldRun() public méthode

Determine whether an experiment should run based on chance.
public shouldRun ( ) : boolean
Résultat boolean

trial() public méthode

Register a trial callback.
public trial ( string $name, callable $callback )
$name string
$callback callable

Property Details

$chance protected_oe property

Execution chance.
protected int $chance
Résultat integer

$control protected_oe property

The control callback.
protected callable $control
Résultat callable

$laboratory protected_oe property

Laboratory instance.
protected Laboratory,Scientist $laboratory
Résultat Laboratory

$matcher protected_oe property

Matcher for experiment values.
protected Matcher,Scientist\Matchers $matcher
Résultat Scientist\Matchers\Matcher

$name protected_oe property

Experiment name.
protected string $name
Résultat string

$params protected_oe property

Parameters for our callbacks.
protected array $params
Résultat array

$trials protected_oe property

Trial callbacks.
protected array $trials
Résultat array