temp = $this->wind = [ 'high' => null, 'low' => null, 'mean' => 0 ]; } /** * Analyse a single Time-object * * @param Time $t The time object. * @return Statistics */ public function analyse(Time $t): self { $this->analyseHihgLow($t->getTemperature()); $this->analyseHihgLow($t->getWindSpeed()); $this->temp['mean'] += $t->getTemperature()->getValue(); $this->wind['mean'] += $t->getWindSpeed()->getValue(); return $this; } private function analyseHihgLow(AbstractUnit $au): self { $unit = null; if ($au instanceof Temperature) $unit = &$this->temp; elseif ($au instanceof WindSpeed) $unit = &$this->wind; else return $this; if ($unit['low'] == null || $au->getValue() < $unit['low']->getValue()) $unit['low'] = $au; if ($unit['high'] == null || $au->getValue() < $unit['high']->getValue()) $unit['high'] = $au; return $this; } } ?>