public static function getSingleTimeValue($dimension, $time, $values) { //do we have value for exact time if (array_key_exists($time, $values)) { if ($dimension->mode === "latest" && isset($dimension->maximumAge)) { //for latest, we a have to check the latest avaiable data is not too old $nowTime = date("Y"); $oldestAllowedTime = $nowTime - $dimension->maximumAge; if ($time < $oldestAllowedTime) { //latest available time is too old, bail return; } } $value = $values[$time]; } else { //no we don't, try to around in recent years if ($dimension->mode !== "latest") { $value = Chart::lookAround($dimension, $time, $values); } } return $value; }