setTests($tests); } /** * @param Test[] $tests */ public function setTests(array $tests) { $this->tests = $tests; } /** * @return Test[] */ public function getTests(): array { return $this->tests; } /** * @param string $dts_start Start date/time in local time * @param string $dts_end End date/time in local time * @return Test[] * @throws Exception */ public function filterByDateRange(string $dts_start, string $dts_end): array { $min_unix = strtotime($dts_start); $max_unix = strtotime($dts_end); $tests = array_filter($this->tests, static function(Test $test) use ($min_unix, $max_unix) { $project = $test->getProject(); $dts = $project->dts_report ?: $test->dts_start; $dt = new DateTime($dts . " UTC"); $unix = $dt->format("U"); if($unix < $min_unix) return false; if($unix > $max_unix) return false; return true; }); $this->tests = array_values($tests); return $this->tests; } }