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 testClassToFileConversionStyle2NoNamespaces() { // Delete all files/ $this->deleteFiles('/tmp/', '/tmp/'); $classyfile = new ClassyFile(); $dispatcher = new EventDispatcher(); $classyfile->setEventDispatcher($dispatcher); $codeLocation = __DIR__ . '/mock/src/VendorName/ProjectName/Category/ProductName/v123456/'; $codeDestination = '/tmp/'; $classyfile->generateClassFiles($codeDestination, $codeLocation); $this->assertFileExists('/tmp/tmp/Date.php'); $this->assertFileExists('/tmp/tmp/DateRange.php'); $this->assertFileExists('/tmp/tmp/OrderBy.php'); // Delete all files/ $this->deleteFiles($codeDestination, '/tmp/'); }