incomes = new Collection; } /** * @param stdClass $entry */ public function addOrCreateIncome(stdClass $entry) { $this->incomes->put($entry->id, $entry); } /** * @param string $add */ public function addToTotal(string $add) { $add = strval(round($add, 2)); $this->total = bcadd($this->total, $add); } /** * @return Collection */ public function getIncomes(): Collection { $set = $this->incomes->sortByDesc( function (stdClass $object) { return $object->amount; } ); return $set; } /** * @return string */ public function getTotal(): string { return strval(round($this->total, 2)); } }