Command/RotateCommand.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $service_name = $input->getArgument('service');
        if (!$this->getContainer()->has($service_name)) {
            $output->writeln(sprintf('<error>The service "%s" does not exist.</error>', $service_name));

            return 1;
        }
        $service = $this->getContainer()->get($service_name);
        if (!$service instanceof JWKSetInterface) {
            $output->writeln(sprintf('<error>The service "%s" is not a key set.</error>', $service_name));

            return 2;
        }

        if (!$service instanceof RotatableInterface) {
            $output->writeln(sprintf('<error>The service "%s" is not a rotatable key set.</error>', $service_name));

            return 3;
        }

        $mtime = $service->getLastModificationTime();

        if (null === $mtime) {
            $service->regen();
            $output->writeln('Done.');
        } elseif ($mtime + $input->getArgument('ttl') <= time()) {
            $service->rotate();
            $output->writeln('Done.');
        } else {
            $output->writeln(sprintf('The key set "%s" has not expired.', $service_name));
        }
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $service_name = $input->getArgument('service');
        if (!$this->getContainer()->has($service_name)) {
            $output->writeln(sprintf('<error>The service "%s" does not exist.</error>', $service_name));

            return 1;
        }
        $service = $this->getContainer()->get($service_name);
        if (!$service instanceof JWKSetInterface) {
            $output->writeln(sprintf('<error>The service "%s" is not a key set.</error>', $service_name));

            return 2;
        }

        if (!$service instanceof RotatableInterface) {
            $output->writeln(sprintf('<error>The service "%s" is not a rotatable key set.</error>', $service_name));

            return 3;
        }

        $mtime = $service->getLastModificationTime();

        if (null === $mtime) {
            $service->regen();
            $output->writeln('Done.');
        } elseif ($mtime + $input->getArgument('ttl') <= time()) {
            $service->rotate();
            $output->writeln('Done.');
        } else {
            $output->writeln(sprintf('The key set "%s" has not expired.', $service_name));
        }
    }
{@inheritdoc}