/**
  * @param Product $product
  *
  * @return bool
  */
 private function productExists(Product $product)
 {
     return $this->findBy(['title' => $product->title()]);
 }
 /**
  * @param Product $product
  */
 public function addProduct(Product $product)
 {
     if (!isset($this->products[$product->title()])) {
         $this->products[$product->title()] = $product;
     }
 }
 /**
  * @param Product $product
  *
  * @throws ProductAlreadyExistsException
  */
 private function assertProductDoesNotExists(Product $product)
 {
     $products = $this->products();
     foreach ($products as $existingProduct) {
         if ($existingProduct->id() === $product->id()) {
             throw new ProductAlreadyExistsException(sprintf('Product with id: %s already exists', $product->id()));
         }
     }
 }