getControl() public method

Get the control result instance.
public getControl ( ) : Result
return Result
Example #1
0
 public function test_that_report_can_hold_control_result()
 {
     $r = new Result();
     $rp = new Report('foo', $r, []);
     $this->assertInstanceOf(Result::class, $rp->getControl());
     $this->assertSame($r, $rp->getControl());
 }
Example #2
0
 public function test_that_report_can_hold_control_result()
 {
     $r = new Result();
     $rp = new Report('foo', $r, array());
     $this->assertInstanceOf('\\Scientist\\Result', $rp->getControl());
     $this->assertSame($r, $rp->getControl());
 }
 /**
  * Dispatch a report to storage.
  *
  * @param \Scientist\Experiment $experiment
  * @param \Scientist\Report     $report
  * @return mixed
  */
 public function report(Experiment $experiment, Report $report)
 {
     $this->experiment = $experiment;
     $this->report = $report;
     $results = $report->getTrials();
     if (isset($results['control'])) {
         throw new Exception('Please use a trial name other than "control"');
     }
     $results['control'] = $report->getControl();
     /** @var Result $result */
     foreach ($results as $key => $result) {
         $data_array = [$this->config->getIsMatchKey() => $result->isMatch(), $this->config->getStartTimeKey() => $result->getStartTime(), $this->config->getEndTimeKey() => $result->getEndTime(), $this->config->getTimeKey() => $result->getTime(), $this->config->getStartMemoryKey() => $result->getStartMemory(), $this->config->getEndMemoryKey() => $result->getEndMemory(), $this->config->getMemoryKey() => $result->getMemory()];
         if ($this->config->shouldReportValue()) {
             $data_array[$this->config->getValueKey()] = $this->config->formatValue($result->getValue());
         }
         $this->logger->{$this->config->getLevel()}($this->config->formatMessage($experiment, $report, $result, $key), $data_array);
     }
 }