PHP Класс Scientist\Experiment

An experiment allows us to implement our code in a new way without risking the introduction of bugs or regressions.
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$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.

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

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

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

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

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

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

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

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

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

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

Get the execution chance.
public getChance ( ) : integer
Результат integer

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

Fetch the control callback.
public getControl ( ) : callable
Результат callable

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

Retrieve the laboratory instance.
public getLaboratory ( ) : Laboratory | null
Результат Laboratory | null

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

Get the matcher for this experiment.
public getMatcher ( ) : Scientist\Matchers\Matcher
Результат Scientist\Matchers\Matcher

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

Fetch the experiment name.
public getName ( ) : string
Результат string

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

Get the experiment parameters.
public getParams ( ) : array
Результат array

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

Fetch a trial callback by name.
public getTrial ( string $name ) : mixed
$name string
Результат mixed

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

Fetch an array of trial callbacks.
public getTrials ( ) : array
Результат array

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

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

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

Execute the experiment and return a report.
public report ( ) : Report
Результат Report

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

Execute the experiment within the laboratory.
public run ( ) : mixed
Результат mixed

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

Determine whether an experiment should run based on chance.
public shouldRun ( ) : boolean
Результат boolean

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

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

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

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

Execution chance.
protected int $chance
Результат integer

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

The control callback.
protected callable $control
Результат callable

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

Laboratory instance.
protected Laboratory,Scientist $laboratory
Результат Laboratory

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

Matcher for experiment values.
protected Matcher,Scientist\Matchers $matcher
Результат Scientist\Matchers\Matcher

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

Experiment name.
protected string $name
Результат string

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

Parameters for our callbacks.
protected array $params
Результат array

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

Trial callbacks.
protected array $trials
Результат array