/** * @param array $earned * @param array $spent * @param Carbon $start * @param Carbon $end * * @return array */ protected function singleYearInOut(array $earned, array $spent, Carbon $start, Carbon $end) { // per month? simply use each month. $entries = new Collection(); while ($start < $end) { // total income and total expenses: $date = $start->format('Y-m'); $incomeSum = isset($earned[$date]) ? $earned[$date] : 0; $expenseSum = isset($spent[$date]) ? $spent[$date] * -1 : 0; $entries->push([clone $start, $incomeSum, $expenseSum]); $start->addMonth(); } $data = $this->generator->yearInOut($entries); return $data; }