stats = new Statistics(); if ($xml != null) foreach ($xml->time as $time) $this->addTime(new Time($time)); } protected function addTime(Time $time): self { $this->time[] = $time; $this->stats->analyse($time); return $this; } public function getStatistics(): array { return $this->stats; } public function getBetween(\DateTimeInterface $from, \DateTimeInterface $until): self { $n = new Tabular(null); foreach ($this as $time) if ($time->getFrom() >= $from && $time->getUntil() <= $until) $n->addTime($time); return $n; } public function getIterator(): \Generator { foreach ($this->time as $time) yield $time; } }