diff --git a/src/Console/Command/InspectMethodCommand.php b/src/Console/Command/InspectMethodCommand.php index 80f6fe1..06ca9cf 100644 --- a/src/Console/Command/InspectMethodCommand.php +++ b/src/Console/Command/InspectMethodCommand.php @@ -16,8 +16,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use function Psl\Iter\contains; +use function Psl\Str\Byte\lowercase; use function Psl\Type\non_empty_string; use function Psl\Vec\filter; +use function Psl\Vec\map; final class InspectMethodCommand extends Command { @@ -33,7 +36,7 @@ protected function configure(): void { $this->setDescription('Inspects a method of a WSDL file.'); $this->addArgument('wsdl', InputArgument::REQUIRED, 'Provide the URI of the WSDL you want to validate'); - $this->addArgument('method', InputArgument::REQUIRED, 'What WSDL method do you want to inspect?'); + $this->addArgument('methods', InputArgument::IS_ARRAY, 'What WSDL method do you want to inspect?'); $this->addOption('loader', 'l', InputOption::VALUE_REQUIRED, 'Customize the WSDL loader file that will be used'); } @@ -42,7 +45,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $style = new SymfonyStyle($input, $output); $loader = ConfiguredLoader::createFromConfig($input->getOption('loader')); $wsdl = non_empty_string()->assert($input->getArgument('wsdl')); - $method = $input->getArgument('method'); + $methods = $input->getArgument('methods'); + $normalize = lowercase(...); + $normalizedMethods = map($methods, static fn (string $method) => $normalize($method)); $style->info('Loading "'.$wsdl.'"...'); @@ -50,9 +55,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $metadataProvider = new Wsdl1MetadataProvider($wsdl); $metadata = $metadataProvider->getMetadata(); - $detectedMethods = filter($metadata->getMethods(), static fn (Method $methodInfo): bool => $methodInfo->getName() === $method); + $detectedMethods = filter( + $metadata->getMethods(), + static fn (Method $methodInfo): bool => contains($normalizedMethods, $normalize($methodInfo->getName())) + ); + if (!$detectedMethods) { - $style->error('Unable to find method '.$method); + $style->error('Unable to find methods '.join(', ', $methods)); return self::FAILURE; } diff --git a/src/Console/Command/InspectTypeCommand.php b/src/Console/Command/InspectTypeCommand.php index 4daaeda..df7ce3e 100644 --- a/src/Console/Command/InspectTypeCommand.php +++ b/src/Console/Command/InspectTypeCommand.php @@ -16,7 +16,10 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use function Psl\Iter\contains; +use function Psl\Str\Byte\lowercase; use function Psl\Type\non_empty_string; +use function Psl\Vec\map; final class InspectTypeCommand extends Command { @@ -32,7 +35,7 @@ protected function configure(): void { $this->setDescription('Inspects types from WSDL file.'); $this->addArgument('wsdl', InputArgument::REQUIRED, 'Provide the URI of the WSDL you want to validate'); - $this->addArgument('type', InputArgument::REQUIRED, 'What WSDL type do you want to inspect?'); + $this->addArgument('types', InputArgument::IS_ARRAY, 'What WSDL type do you want to inspect?'); $this->addOption('loader', 'l', InputOption::VALUE_REQUIRED, 'Customize the WSDL loader file that will be used'); } @@ -41,7 +44,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $style = new SymfonyStyle($input, $output); $loader = ConfiguredLoader::createFromConfig($input->getOption('loader')); $wsdl = non_empty_string()->assert($input->getArgument('wsdl')); - $typeName = $input->getArgument('type'); + $typeNames = $input->getArgument('types'); + $normalize = lowercase(...); + $normalizedTypeNames = map($typeNames, static fn (string $type) => $normalize($type)); $style->info('Loading "'.$wsdl.'"...'); @@ -49,9 +54,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $metadataProvider = new Wsdl1MetadataProvider($wsdl); $metadata = $metadataProvider->getMetadata(); - $detectedTypes = $metadata->getTypes()->filter(static fn (Type $type): bool => $type->getName() === $typeName); + $detectedTypes = $metadata->getTypes()->filter( + static fn (Type $type): bool => contains($normalizedTypeNames, $normalize($type->getName())) + ); if (!$detectedTypes->count()) { - $style->error('Unable to find type '.$typeName); + $style->error('Unable to find types '.join(', ', $typeNames)); return self::FAILURE; }