From bdaaa94311335110bd11ebb865b528cea8d382aa Mon Sep 17 00:00:00 2001 From: andreas-gruenwald Date: Mon, 27 Nov 2023 16:17:26 +0100 Subject: [PATCH 1/2] Avoid exception on empty configration prefix --- src/VoucherService/TokenManager/Pattern.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VoucherService/TokenManager/Pattern.php b/src/VoucherService/TokenManager/Pattern.php index 5d09e6af..54c4eff8 100644 --- a/src/VoucherService/TokenManager/Pattern.php +++ b/src/VoucherService/TokenManager/Pattern.php @@ -257,16 +257,16 @@ public function getFinalTokenLength(): int { $separatorCount = $this->configuration->getSeparatorCount(); $separator = $this->configuration->getSeparator(); - $prefix = $this->configuration->getPrefix(); + $prefix = $this->configuration->getPrefix() ?? ''; if (!empty($separator)) { if (!empty($prefix)) { - return strlen($this->configuration->getPrefix()) + 1 + (int) floor($this->configuration->getLength() / $separatorCount) + $this->configuration->getLength(); + return strlen($prefix) + 1 + (int) floor($this->configuration->getLength() / $separatorCount) + $this->configuration->getLength(); } return (int) floor($this->configuration->getLength() / $separatorCount) + $this->configuration->getLength(); } - return strlen($this->configuration->getPrefix()) + $this->configuration->getLength(); + return strlen($prefix) + $this->configuration->getLength(); } /** From ff86d9181520bae22ddb8c70c5ec8dce52ad248f Mon Sep 17 00:00:00 2001 From: andreas-gruenwald Date: Tue, 5 Dec 2023 22:33:30 +0100 Subject: [PATCH 2/2] Optimize code Force cla reverification. --- src/VoucherService/TokenManager/Pattern.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VoucherService/TokenManager/Pattern.php b/src/VoucherService/TokenManager/Pattern.php index 54c4eff8..572a8638 100644 --- a/src/VoucherService/TokenManager/Pattern.php +++ b/src/VoucherService/TokenManager/Pattern.php @@ -257,7 +257,7 @@ public function getFinalTokenLength(): int { $separatorCount = $this->configuration->getSeparatorCount(); $separator = $this->configuration->getSeparator(); - $prefix = $this->configuration->getPrefix() ?? ''; + $prefix = (string)$this->configuration->getPrefix(); if (!empty($separator)) { if (!empty($prefix)) { return strlen($prefix) + 1 + (int) floor($this->configuration->getLength() / $separatorCount) + $this->configuration->getLength();