Skip to content

Commit

Permalink
update filter usage
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Sep 17, 2022
1 parent 81c581d commit 2d1085d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Console/Generate/SdkCommand.php
Expand Up @@ -87,7 +87,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$config = $this->getConfig($input);
$filter = $this->getFilter($input);
$filter = null;
$filterName = $input->getOption('filter');
if (!empty($filterName)) {
$filter = $this->filterFactory->getFilter($filterName);
if ($filter === null) {
throw new \RuntimeException('Provided an invalid filter name');
}
}

$generator = $this->factory->getGenerator($format, $config);
$extension = $this->factory->getFileExtension($format, $config);
Expand Down Expand Up @@ -119,22 +126,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 1;
}

private function getConfig(InputInterface $input): string
private function getConfig(InputInterface $input): ?string
{
$namespace = $input->getOption('namespace');
$options = [];
if (!empty($namespace)) {
$options['namespace'] = $namespace;
}

return http_build_query($options);
}

private function getFilter(InputInterface $input): ?FilterInterface
{
$filterName = $input->getOption('filter');
if (!empty($filterName)) {
return $this->filterFactory->getFilter($filterName);
if (!empty($options)) {
return http_build_query($options);
} else {
return null;
}
Expand Down

0 comments on commit 2d1085d

Please sign in to comment.