/**
  * Download a replay.
  *
  * If the asynchronous parameter is set to "true", make sure the CLI dependency is installed :
  * @see https://github.com/EloGank/lol-replay-downloader-cli
  *
  * @param string               $region
  * @param int                  $gameId
  * @param string               $encryptionKey
  * @param null|OutputInterface $output
  * @param bool                 $isOverride    If the replay folder already exists, override it (causes loss of previous files !)
  * @param bool                 $isAsync       True if the download will be in asynchronous mode, false otherwise
  * @param string               $consolePath   The absolute path to the "console" file in the CLI dependency folder
  *
  * @return Replay
  *
  * @throws GameNotFoundException
  */
 public function download($region, $gameId, $encryptionKey, OutputInterface $output = null, $isOverride = false, $isAsync = false, $consolePath = null)
 {
     // Check if exists
     if (!$this->client->isGameExists($region, $gameId)) {
         throw new GameNotFoundException('The game #' . $gameId . ' is not found');
     }
     // Create directories
     if ($isOverride) {
         if (!is_dir($this->getReplayDirPath($region, $gameId))) {
             $this->createDirs($region, $gameId);
         }
     } else {
         $this->createDirs($region, $gameId);
     }
     if ($isAsync) {
         // Check for the CLI dependency
         if (!class_exists('\\EloGank\\Replay\\Command\\ReplayDownloadCommand')) {
             throw new \RuntimeException('The dependency to run the async download is missing. Please, see : https://github.com/EloGank/lol-replay-downloader-cli');
         }
         $replayFolder = $this->getReplayDirPath($region, $gameId);
         return pclose(popen(sprintf('%s %s/console elogank:replay:download %s %d %s --override > %s/info.log 2>&1 & echo $! > %s/pid', $this->options['php.executable_path'], $consolePath, $region, $gameId, $encryptionKey, $replayFolder, $replayFolder), 'r'));
     }
     return $this->doDownload($region, $gameId, $encryptionKey, $output);
 }