protected function execute(InputInterface $input, OutputInterface $output)
 {
     $codeLocation = $input->getArgument('code-location');
     $codeDestination = $input->getOption('code-destination');
     $createNamespace = $input->getOption('create-namespace');
     $offset = $input->getOption('offset');
     $length = $input->getOption('length');
     $classyfile = new ClassyFile();
     $dispatcher = new EventDispatcher();
     if ($input->getOption('constants-to-upper')) {
         $plugin = new ConstantNamesToUpper();
         $dispatcher->addSubscriber($plugin);
     }
     if ($input->getOption('psr-fix')) {
         $plugin = new PhpCsFixer($input, $output);
         $dispatcher->addSubscriber($plugin);
     }
     if ($input->getOption('remove-top-comment')) {
         $classyfile->setTemplate(new BasicClassTemplate(''), 'getTemplate');
     }
     $classyfile->setEventDispatcher($dispatcher);
     if ($createNamespace) {
         $classyfile->generateClassFiles($codeDestination, $codeLocation, $offset, $length);
     } else {
         $classyfile->generateClassFiles($codeDestination, $codeLocation);
     }
 }
Exemple #2
0
 public function testErrorException()
 {
     $this->setExpectedException('\\Onema\\ClassyFile\\Exception\\ClassToFileRuntimeException');
     $classyfile = new ClassyFile();
     $codeLocation = __DIR__ . '/mock/bad/';
     $classyfile->generateClasses($codeLocation);
 }