/** * {@inheritdoc} * @throws \Phpro\SoapClient\Exception\InvalidArgumentException */ protected function execute(InputInterface $input, OutputInterface $output) { $configFile = $input->getOption('config'); if (!$configFile || !$this->filesystem->fileExists($configFile)) { throw InvalidArgumentException::invalidConfigFile(); } $config = (include $configFile); if (!$config instanceof ConfigInterface) { throw InvalidArgumentException::invalidConfigFile(); } $soapClient = new SoapClient($config->getWsdl(), $config->getSoapOptions()); $typeMap = TypeMap::fromSoapClient($config->getNamespace(), $soapClient); $file = new FileGenerator(); $generator = new ClassMapGenerator($config->getRuleSet()); $output->write($generator->generate($file, $typeMap)); }
/** * @param InputInterface $input * @param OutputInterface $output * @param string $file * @param string $name * @param string $newContent */ protected function handleExistingFile(InputInterface $input, OutputInterface $output, $file, $name, $newContent) { // Patch the file $patched = $this->patchExistingFile($output, $file, $newContent); if ($patched) { $output->writeln('Patched!'); return; } $output->writeln('Could not patch.'); // Ask for overwriting the file: $allowOverwrite = $this->askForOverwrite($input, $output, $newContent); if (!$allowOverwrite) { $output->writeln(sprintf('Skipping %s', $name)); return; } // Overwrite $this->filesystem->putFileContents($file, $newContent); }
/** * Generates one type class * * @param FileGenerator $file * @param TypeGenerator $generator * @param Type $type * @param string $path */ protected function generateType(FileGenerator $file, TypeGenerator $generator, Type $type, $path) { $code = $generator->generate($file, $type); $this->filesystem->putFileContents($path, $code); }
/** * @param array $files */ protected function cleanTmpFiles(array $files) { foreach ($files as $file) { $this->filesystem->removeFile($file); } }