categories = new Collection; } /** * @param CategoryModel $category */ public function addCategory(CategoryModel $category) { if ($category->spent > 0) { $this->categories->push($category); } } /** * @param float $add */ public function addTotal($add) { $this->total += floatval($add); } /** * @return Collection */ public function getCategories() { $this->categories->sortByDesc( function (CategoryModel $category) { return $category->spent; } ); return $this->categories; } /** * @return float */ public function getTotal() { return $this->total; } }