Kelunik\AcmeClient\Stores\KeyStore::doPut PHP Method

doPut() private method

private doPut ( $path, KeyPair $keyPair )
$keyPair Kelunik\Acme\KeyPair
    private function doPut($path, KeyPair $keyPair)
    {
        if (!is_string($path)) {
            throw new InvalidArgumentException(sprintf("\$root must be of type string, %s given.", gettype($path)));
        }
        $file = $this->root . "/" . $path;
        try {
            // TODO: Replace with async version once available
            if (!file_exists(dirname($file))) {
                $success = mkdir(dirname($file), 0755, true);
                if (!$success) {
                    throw new KeyStoreException("Could not create key store directory.");
                }
            }
            (yield \Amp\File\put($file, $keyPair->getPrivate()));
            (yield \Amp\File\chmod($file, 0600));
        } catch (FilesystemException $e) {
            throw new KeyStoreException("Could not save key.", 0, $e);
        }
        (yield new CoroutineResult($keyPair));
    }