From bfdc5eb780b477660749bf9ea9fe681e01bfbb70 Mon Sep 17 00:00:00 2001 From: Dani Esteban Date: Mon, 9 May 2022 11:45:58 +0200 Subject: [PATCH] AD-231 Consolidate variable name to expires as it can not contain options --- src/Sifo/Cookie.php | 4 ++-- test/Sifo/CookieTest.php | 6 +++--- test/Sifo/TestCookie.php | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Sifo/Cookie.php b/src/Sifo/Cookie.php index 19111f6b..b8b4609a 100644 --- a/src/Sifo/Cookie.php +++ b/src/Sifo/Cookie.php @@ -136,10 +136,10 @@ static private function _sanitizeCookie( $cookie ) return false; } - static protected function setCookie(string $name, $value = "", $expires_or_options = 0, $path = "", $domain = "", $secure = false, $httponly = false, string $samesite = null): bool + static protected function setCookie(string $name, $value = "", $expires = 0, $path = "", $domain = "", $secure = false, $httponly = false, string $samesite = null): bool { $options = [ - 'expires' => $expires_or_options, + 'expires' => $expires, 'path' => $path, 'domain' => $domain, 'secure' => $secure, diff --git a/test/Sifo/CookieTest.php b/test/Sifo/CookieTest.php index aa53fecb..304d73bd 100644 --- a/test/Sifo/CookieTest.php +++ b/test/Sifo/CookieTest.php @@ -21,7 +21,7 @@ public function testCookieIsSetWithExpectedDefaults(): void $this->assertEquals( $defaultExpiration, - TestCookie::getExpiresOrOptions($cookieName), + TestCookie::getExpires($cookieName), "Expires doesn't match with expected." ); $this->assertSame( @@ -45,7 +45,7 @@ public function testCookieCanBeSetWithoutExpiration(): void TestCookie::set($cookieName, 'oreo', 0); - $this->assertSame(0, TestCookie::getExpiresOrOptions($cookieName)); + $this->assertSame(0, TestCookie::getExpires($cookieName)); } public function testCookieIsSetWithCustomParameters(): void @@ -58,7 +58,7 @@ public function testCookieIsSetWithCustomParameters(): void $this->assertEquals( $defaultExpiration, - TestCookie::getExpiresOrOptions($cookieName), + TestCookie::getExpires($cookieName), "Expires doesn't match with expected." ); $this->assertSame( diff --git a/test/Sifo/TestCookie.php b/test/Sifo/TestCookie.php index 7944c792..1594368c 100644 --- a/test/Sifo/TestCookie.php +++ b/test/Sifo/TestCookie.php @@ -11,7 +11,7 @@ class TestCookie extends Cookie protected static function setCookie( string $name, $value = "", - $expires_or_options = 0, + $expires = 0, $path = "", $domain = "", $secure = false, @@ -26,7 +26,7 @@ protected static function setCookie( self::$cookies[$name] = [ 'value' => $value, - 'expires_or_options' => $expires_or_options, + 'expires' => $expires, 'path' => $path, 'domain' => $domain, 'secure' => $secure, @@ -55,9 +55,9 @@ public static function getValue(string $name): string return (string) self::getCookieParam($name, 'value'); } - public static function getExpiresOrOptions(string $name) + public static function getExpires(string $name) { - return self::getCookieParam($name, 'expires_or_options'); + return self::getCookieParam($name, 'expires'); } public static function getPath(string $name): string