/**
  * ZIPアーカイブを解析し、ファイルの矯正を行います。
  * @param \SplFileInfo $file
  * @throws SyntaxException
  * @return \SplFileInfo
  */
 protected function parseArchive(\SplFileInfo $file) : \SplFileInfo
 {
     $archive = new ZipOutputFile(ZipFile::openFromFile($file instanceof \SplTempFileObject ? $this->generateTempFile($file) : $file->getRealPath()));
     $this->correctArchiveFilenamesEncoding($archive);
     $this->flattenArchive($archive);
     $this->filenames = $this->correctArchiveFilenames($archive);
     $tempDirectoryPath = (new GenericDictionaryParser())->generateTempDirectory();
     $archive->extractTo($tempDirectoryPath);
     $archive->close();
     $validator = new \esperecyan\dictionary_php\Validator();
     $validator->setLogger($this->logger);
     foreach (new \FilesystemIterator($tempDirectoryPath, \FilesystemIterator::KEY_AS_FILENAME) as $filename => $file) {
         if ($file->getExtension() === 'txt') {
             if (isset($quizFile)) {
                 throw new SyntaxException(_('拡張子が「.txt」のファイルが2つ以上含まれています。'));
             }
             if (!in_array((new Finfo(FILEINFO_MIME_TYPE))->file($file), ['text/plain', 'text/csv'])) {
                 throw new SyntaxException(sprintf(_('「%s」は通常のテキストファイルとして認識できません。'), $filename));
             }
             $quizFile = $file;
         }
     }
     if (empty($quizFile)) {
         throw new SyntaxException(_('拡張子が「.txt」のファイルが見つかりません。'));
     }
     return $quizFile;
 }