Kelunik\AcmeClient\Commands\Check::doExecute PHP Method

doExecute() private method

private doExecute ( League\CLImate\Argument\Manager $args ) : Generator
$args League\CLImate\Argument\Manager
return Generator
    private function doExecute(Manager $args)
    {
        $server = \Kelunik\AcmeClient\resolveServer($args->get("server"));
        $server = \Kelunik\AcmeClient\serverToKeyname($server);
        $path = \Kelunik\AcmeClient\normalizePath($args->get("storage")) . "/certs/" . $server;
        $certificateStore = new CertificateStore($path);
        try {
            $pem = (yield $certificateStore->get($args->get("name")));
        } catch (CertificateStoreException $e) {
            $this->climate->br()->error("    Certificate not found.")->br();
            (yield new CoroutineResult(1));
            return;
        }
        $cert = new Certificate($pem);
        $this->climate->br();
        $this->climate->whisper("    Certificate is valid until " . date("d.m.Y", $cert->getValidTo()))->br();
        if ($args->defined("names")) {
            $names = array_map("trim", explode(",", $args->get("names")));
            $missingNames = array_diff($names, $cert->getNames());
            if ($missingNames) {
                $this->climate->comment("    The following names are not covered: " . implode(", ", $missingNames))->br();
                (yield new CoroutineResult(1));
                return;
            }
        }
        if ($cert->getValidTo() > time() + $args->get("ttl") * 24 * 60 * 60) {
            (yield new CoroutineResult(0));
            return;
        }
        $this->climate->comment("    Certificate is going to expire within the specified " . $args->get("ttl") . " days.")->br();
        (yield new CoroutineResult(1));
    }