/**
  * @param Command $command
  *
  * @return mixed|void
  * @throws RestaurantAlreadyExistsException
  */
 public function handle(Command $command)
 {
     if ($this->repository->hasRestaurant($command->restaurantName)) {
         throw new RestaurantAlreadyExistsException("Restaurant already exists.");
     }
     $restaurant = $this->restaurantFactory->createRestaurant($this->repository->nextIdentity(), $command);
     $this->repository->add($restaurant);
 }
 /**
  * @param Command|Command\AddNewMenuCardToRestaurantCommand $command
  *
  * @return mixed
  * @throws RestaurantDoesNotExistException
  */
 public function handle(Command $command)
 {
     /** @var Restaurant $restaurant */
     $restaurant = $command->restaurant;
     if (!$this->repository->hasRestaurant($restaurant->getRestaurantName())) {
         throw new RestaurantDoesNotExistException("restaurant does not exist.");
     }
     $restaurant->createMenuCardForRestaurant($command->title);
     $this->repository->add($restaurant);
 }