| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- class TestResultSet {
- /** @var Test[] */
- private $tests = [];
- public function __construct(array $tests = []) {
- $this->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[]
- */
- 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, 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;
- }
- }
|