Skip to content

Commit

Permalink
Some optimizations in the Reusable.php class
Browse files Browse the repository at this point in the history
Switch has only single case, it is replaced with 'if'.
Add '?\DateInterval' as the property's type of $tokenLifetime
  • Loading branch information
jeijei4 authored Mar 8, 2024
1 parent 563a779 commit c0b92cc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Reusable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Reusable extends AntiCSRF
/**
* @var \DateInterval|null
*/
protected $tokenLifetime = null;
protected ?\DateInterval $tokenLifetime = null;

/**
* @param \DateInterval $interval
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c0b92cc

Please sign in to comment.