/**
  * Handle re-schedule movie.
  *
  * @param RescheduleMovieCommand $command
  * @param MovieRepository        $repository
  *
  * @return MovieThatWereScheduled
  */
 public function handle(RescheduleMovieCommand $command, MovieRepository $repository)
 {
     /** @var Movie $movie */
     $movie = $repository->find($command->id);
     $movie->reschedule($command->schedule);
     return $repository->persist($movie);
 }
 /**
  * Handle book a ticket command.
  *
  * @param BookTicketCommand $command
  * @param MovieRepository   $repository
  */
 public function handle(BookTicketCommand $command, MovieRepository $repository)
 {
     /** @var Movie $movie */
     $movie = $repository->find($command->movieId);
     $movie->book($command->id, $command->booked);
     return $repository->persist($movie);
 }
 /**
  * Handle cancel ticket command.
  *
  * @param CancelTicketCommand $command
  * @param MovieRepository     $repository
  *
  * @return TicketThatWereBooked
  */
 public function handle(CancelTicketCommand $command, MovieRepository $repository)
 {
     /** @var Movie $movie */
     $movie = $repository->find($command->movieId);
     $ticket = $movie->books->findById($command->id);
     if (null === $ticket) {
         throw new \InvalidArgumentException(sprintf('Ticket with id "%s" is undefined.', (string) $command->id));
     }
     $ticket->cancel();
     return $repository->persist($movie);
 }
 /**
  * Handle schedule new movie.
  *
  * @param ScheduleMovieCommand $command
  * @param MovieRepository      $repository
  *
  * @return MovieThatWereScheduled[]
  */
 public function handle(ScheduleMovieCommand $command, MovieRepository $repository)
 {
     $movie = Movie::schedule($command->id, $command->name, $command->schedule, $command->price);
     return $repository->persist($movie);
 }