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); } }
public function testBadTemplate() { $this->setExpectedException('\\Onema\\ClassyFile\\Exception\\InvalidTemplateException', 'The template must be callable.'); $classyfile = new ClassyFile(); $classyfile->setTemplate('FooBar'); }