public function getId() { return $this->id; }
public function addCategory(Category $category) { $categoryId = $category->getId(); if ($this->hasCategory($categoryId)) { throw new \Exception(sprintf('Category %s already exists', $categoryId)); } $this->categories[$categoryId] = $category; }