PhpBench\Model\ResultCollection::getResult PHP Method

getResult() public method

Return the result of the given class, throw an exception if it does not exist.
public getResult ( string $class ) : PhpBench\Model\ResultInterface
$class string
return PhpBench\Model\ResultInterface
    public function getResult($class)
    {
        if (!isset($this->results[$class])) {
            throw new \RuntimeException(sprintf('Result of class "%s" has not been set', $class));
        }
        return $this->results[$class];
    }

Usage Example

 /**
  * It can have results added in the constructor.
  */
 public function testAddConstructor()
 {
     $collection = new ResultCollection([$expected = new TimeResult(10)]);
     $result = $collection->getResult(TimeResult::class);
     $this->assertSame($expected, $result);
 }