From c0b92cca277b5c65e61af2ddec6d31b3251ea17c Mon Sep 17 00:00:00 2001 From: JeiHO Date: Fri, 8 Mar 2024 16:35:58 -0600 Subject: [PATCH] Some optimizations in the Reusable.php class Switch has only single case, it is replaced with 'if'. Add '?\DateInterval' as the property's type of $tokenLifetime --- src/Reusable.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Reusable.php b/src/Reusable.php index 3b6a8bd..20f138c 100644 --- a/src/Reusable.php +++ b/src/Reusable.php @@ -21,7 +21,7 @@ class Reusable extends AntiCSRF /** * @var \DateInterval|null */ - protected $tokenLifetime = null; + protected ?\DateInterval $tokenLifetime = null; /** * @param \DateInterval $interval @@ -57,12 +57,9 @@ public function reconfigure(array $options = []): AntiCSRF /** @var string $opt */ /** @var \DateInterval $val */ foreach ($options as $opt => $val) { - switch ($opt) { - case 'tokenLifetime': - if ($val instanceof \DateInterval) { - $this->tokenLifetime = $val; - } - break; + if ($opt == 'tokenLifetime' && $val instanceof \DateInterval) { + $this->tokenLifetime = $val; + break; } } return parent::reconfigure($options);