time = $time; $var = new Variation($time); foreach($time as $entity) $var->addEntity($entity, null); $this->data[] = $var; foreach ($t as $time) { $var = new Variation($time); foreach($time as $entity) $this->match($var, $entity); if (!$var->isEmpty()) $this->data[] = $var; } array_shift($this->data); } private function match(Variation $var, DiffInterface $entity): void { foreach(array_reverse($this->data) as $data) { foreach ($data as $dentity) { if ($entity instanceof $dentity) { if ($entity->diff($dentity)) $var->addEntity($entity, $data == null ? "NULL" : $data); return; } } } } public function getTime(): Time { return $this->time; } /** * Filter on types, example usage * ``` * $variations->filter(function ($entity) { * return $entity instanceof Temperature; * ); * ``` * * @return \Generator */ public function filter(callable $filterFn): \Generator { foreach ($this as $data) if (($match = $data->filter($filterFn)) != null) yield $match; return null; } /** * {@inheritDoc} */ public function getIterator(): \Generator { foreach ($this->data as $data) yield $data; } }