/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$destination = rtrim($input->getArgument('destination'), '/\\');
if (!$this->filesystem->dirextoryExists($destination)) {
throw new RunTimeException(sprintf('The destination %s does not exist.', $destination));
}
$wsdl = $input->getOption('wsdl');
if (!$wsdl) {
throw new RuntimeException('You MUST specify a WSDL endpoint.');
}
$namespace = $input->getOption('namespace');
$soapClient = new SoapClient($wsdl, []);
$types = $soapClient->getSoapTypes();
$generator = new TypeGenerator($namespace);
foreach ($types as $type => $properties) {
// Check if file exists:
$file = sprintf('%s/%s.php', $destination, ucfirst($type));
$data = $generator->generate($type, $properties);
// Existing files ...
if ($this->filesystem->fileExists($file)) {
$this->handleExistingFile($input, $output, $file, $type, $data);
continue;
}
// New files...
$this->filesystem->putFileContents($file, $data);
$output->writeln(sprintf('Generated class %s to %s', $type, $file));
}
$output->writeln('Done');
}