From b4f2234a2322ab441479ee340b8191374344337e Mon Sep 17 00:00:00 2001 From: Gerd Katzenbeisser Date: Sat, 8 Aug 2020 11:02:48 +0200 Subject: [PATCH] Refactor bas64_url* functions to static --- src/Model/Table/PayPalPaymentsTable.php | 8 ++++---- tests/TestCase/Model/Table/PayPalPaymentsTableTest.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Model/Table/PayPalPaymentsTable.php b/src/Model/Table/PayPalPaymentsTable.php index b0d73b0..ce15063 100644 --- a/src/Model/Table/PayPalPaymentsTable.php +++ b/src/Model/Table/PayPalPaymentsTable.php @@ -181,23 +181,23 @@ public function encryptRedirectUrl($text, $id) $credentials = self::getCredentials(); $compressed = gzcompress($text, 9); $key = $credentials['ClientSecret'] . $id; - return $this->base64_url_encode(Security::encrypt($compressed, $key)) ; + return self::base64_url_encode(Security::encrypt($compressed, $key)) ; } public function decryptRedirectUrl($encryptedText, $id) { $credentials = self::getCredentials(); $key = $credentials['ClientSecret'] . $id; - $compressed = Security::decrypt($this->base64_url_decode($encryptedText), $key); + $compressed = Security::decrypt(self::base64_url_decode($encryptedText), $key); return gzuncompress($compressed); } - public function base64_url_encode($input) + public static function base64_url_encode($input) { return strtr(base64_encode($input) , '+/=', '-_,'); } - public function base64_url_decode($input) + public static function base64_url_decode($input) { return base64_decode(strtr($input, '-_,', '+/=')); } diff --git a/tests/TestCase/Model/Table/PayPalPaymentsTableTest.php b/tests/TestCase/Model/Table/PayPalPaymentsTableTest.php index b571929..e5d0742 100644 --- a/tests/TestCase/Model/Table/PayPalPaymentsTableTest.php +++ b/tests/TestCase/Model/Table/PayPalPaymentsTableTest.php @@ -320,7 +320,7 @@ public function testBase64UrlEncode() $plus = chr(0x3e << 2); $slash = chr(0x3f); $value = "$plus\x0$slash\o\x3Fo"; - $actual = $this->PayPalPayments->base64_url_encode($value); + $actual = PayPalPaymentsTable::base64_url_encode($value); $this->assertEquals('-AA_XG8_bw,,', $actual); } @@ -329,7 +329,7 @@ public function testBase64UrlDecode() $plus = chr(0x3e << 2); $slash = chr(0x3f); $value = "$plus\x0$slash\o\x3Fo"; - $actual = $this->PayPalPayments->base64_url_decode('-AA_XG8_bw,,'); + $actual = PayPalPaymentsTable::base64_url_decode('-AA_XG8_bw,,'); $this->assertEquals($value, $actual); } }