コード例 #1
0
ファイル: publishing.php プロジェクト: LartTyler/Analyst
    public function __construct($name, PDO $db)
    {
        parent::__construct($name);
        $this->db = $db;
        $this->stmt = $db->prepare('insert into experiment_results (experiment, timestamp, behavior, is_control,
				execution_time, result) values (:experiment, UTC_TIMESTAMP, :behavior, :control, :duration, :result)');
        $this->stmt->bindValue(':experiment', $name);
    }
コード例 #2
0
ファイル: ExperimentTest.php プロジェクト: LartTyler/Analyst
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Control code failed
  */
 public function testExperimentForwardsThrownExceptionsFromControl()
 {
     $experiment = Experiment::create()->control(function () {
         throw new \Exception('Control code failed');
     })->candidate(function () {
         return 'noop';
     });
     $experiment->run();
 }
コード例 #3
0
ファイル: usage.php プロジェクト: LartTyler/Analyst
<?php

namespace DaybreakStudios\Analyst\Samples;

use DaybreakStudios\Analyst\Experiment;
require __DIR__ . '/bootstrap.php';
ob_start();
$fullName = 'Tyler Lartonoix';
$name = Experiment::create()->setThrowOnMismatch(true)->setContext(['name' => $fullName])->control(function ($name) {
    $name = trim($name);
    return [substr($name, 0, strpos($name, ' ')), substr($name, strpos($name, ' ') + 1) ?: null];
})->candidate(function ($name) {
    return [strtok(trim($name), ' '), strtok('') ?: null];
})->run();
printf(":: Results\nFull name: %s\nFirst name: %s\nLast name: %s", $fullName, $name[0], $name[1]);
echo ob_get_clean() . "\n";