public function getUnits(Run $run)
{
$stmt = $this->connection->prepare('
SELECT
id, feature, created_at, started_at, finished_at, return_code, output_files
FROM
bl_run_unit
WHERE
run_id = :run_id
');
$stmt->bindValue('run_id', $run->getId());
$stmt->execute();
$units = array();
while ($row = $stmt->fetch()) {
$unit = new RunUnit();
$unit->setRun($run)->setId($row['id'])->setFeature($row['feature'])->setCreatedAt(new \DateTime($row['created_at']))->setStartedAt($row['started_at'] !== null ? new \DateTime($row['started_at']) : null)->setFinishedAt($row['finished_at'] !== null ? new \DateTime($row['finished_at']) : null)->setReturnCode($row['return_code']);
$this->loadOutputFiles($unit->getOutputFiles(), json_decode($row['output_files'], true));
$units[] = $unit;
}
return new RunUnitList($units);
}