Пример #1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $start = microtime(true);
     $encoding = $input->getOption(self::OPTION_ENCODING);
     $codepointValue = $input->getArgument(self::ARGUMENT_CODEPOINT);
     $codepoint = $this->valueToCodepoint($codepointValue, $encoding);
     $from = $input->getOption(self::OPTION_FROM);
     $repository = $this->getRepositoryByName($from);
     $db = new Database($repository);
     $exporter = new Exporter();
     try {
         $character = $db->getCharacterByCodepoint($codepoint);
     } catch (CharacterNotFoundException $e) {
         $output->writeln('<error>Character Not Found</error>');
         return 1;
     }
     $output->writeln('<info>Character Found</info>');
     $output->writeln(sprintf('Export: %s', $exporter->export($character)));
     $output->writeln(sprintf('UTF-8: %s', $codepoint->toUTF8()));
     $output->writeln(sprintf('Memory peak: %.5f MB', memory_get_peak_usage() / 1048576));
     $output->writeln(sprintf('Took: %.5f seconds', microtime(true) - $start));
     return 0;
 }