From 9a3b226781c435c98f72c1a995d7d2d38bbc8931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 11 May 2022 14:09:30 +0000 Subject: [PATCH] PR review changes --- app/workers/certificates.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/workers/certificates.php b/app/workers/certificates.php index 0b6a45f0c3..f1df74972c 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -23,7 +23,7 @@ class CertificatesV1 extends Worker * * @var Database */ - private $dbForConsole; + private Database $dbForConsole; public function getName(): string { return "certificates"; @@ -103,7 +103,7 @@ class CertificatesV1 extends Worker } // Generate certificate files using Let's Encrypt - $letsEncryptData = $this->letsEncryptAction($domain->get(), $email); + $letsEncryptData = $this->issueCertificate($domain->get(), $email); // Command succeeded, store all data into document // We store stderr too, because it may include warnings @@ -135,7 +135,7 @@ class CertificatesV1 extends Worker // Save all changes we made to certificate document into database $this->saveCertificateDocument($domain->get(), $certificate); - + Authorization::reset(); } } @@ -152,7 +152,7 @@ class CertificatesV1 extends Worker * * @return void */ - private function saveCertificateDocument(string $domain, Document $certificate) { + private function saveCertificateDocument(string $domain, Document $certificate): void { // Check if update or insert required $certificateDocument = $this->dbForConsole->findOne('certificates', [ new Query('domain', Query::TYPE_EQUAL, [$domain]) ]); if (!empty($certificateDocument) && !$certificateDocument->isEmpty()) { @@ -175,15 +175,15 @@ class CertificatesV1 extends Worker */ private function getMainDomain(): ?string { if (!empty(App::getEnv('_APP_DOMAIN', ''))) { - $mainDomain = App::getEnv('_APP_DOMAIN', ''); + return App::getEnv('_APP_DOMAIN', ''); } else { $domainDocument = $this->dbForConsole->findOne('domains', [], 0, ['_id'], ['ASC']); if($domainDocument) { - $mainDomain = $domainDocument->getAttribute('domain'); + return $domainDocument->getAttribute('domain'); } } - return $mainDomain; + return null; } /** @@ -262,7 +262,7 @@ class CertificatesV1 extends Worker * * @return array Named array with keys 'stdout' and 'stderr', both string */ - private function letsEncryptAction(string $domain, string $email): array { + private function issueCertificate(string $domain, string $email): array { $staging = (App::isProduction()) ? '' : ' --dry-run'; $stdout = '';