Skip to content

Instantly share code, notes, and snippets.

@maks-rafalko
Created October 14, 2017 21:58
Show Gist options
  • Save maks-rafalko/91048c8d0ddf6935e37a5947b48a00fe to your computer and use it in GitHub Desktop.
Save maks-rafalko/91048c8d0ddf6935e37a5947b48a00fe to your computer and use it in GitHub Desktop.
public function calculateExpectedValueAt(DateTimeInterface $date)
{
$diffInDays = (int) $this->startedAt->diff($date)->format('%a');
$multiplier = $this->initialValue < $this->targetValue ? 1 : -1;
$initialAveragePerDay = $this->calculateInitialAveragePerDay();
- return $this->initialValue + ($initialAveragePerDay * $diffInDays * $multiplier);
+ return $this->initialValue + ($initialAveragePerDay * $diffInDays / $multiplier);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment