Example #1
0
 /**
  * Generate dictionary
  *
  * @param string $directory
  * @param string $outputFilename
  * @param bool $withContext
  * @throws \UnexpectedValueException
  * @return void
  */
 public function generate($directory, $outputFilename, $withContext = false)
 {
     $optionResolver = $this->optionResolverFactory->create($directory, $withContext);
     $parser = $this->getActualParser($withContext);
     $parser->parse($optionResolver->getOptions());
     $phraseList = $parser->getPhrases();
     if (!count($phraseList)) {
         throw new \UnexpectedValueException('No phrases found in the specified dictionary file.');
     }
     foreach ($phraseList as $phrase) {
         $this->getDictionaryWriter($outputFilename)->write($phrase);
     }
     $this->writer = null;
 }