setHelp('This command converts a private key into a public key.') ->addArgument('jwk', InputArgument::REQUIRED, 'The JWK object'); } protected function execute(InputInterface $input, OutputInterface $output): int { $jwk = $this->getKey($input); $jwk = $jwk->toPublic(); $this->prepareJsonOutput($input, $output, $jwk); return self::SUCCESS; } private function getKey(InputInterface $input): JWK { $jwk = $input->getArgument('jwk'); if (! is_string($jwk)) { throw new InvalidArgumentException('Invalid JWK'); } $json = JsonConverter::decode($jwk); if (! is_array($json)) { throw new InvalidArgumentException('Invalid JWK'); } return new JWK($json); } }