Skip to content

Commit 5cf6979

Browse files
committed
refactor: extract method
1 parent 62e0b44 commit 5cf6979

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

system/Session/Handlers/RedisHandler.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ public function __construct(AppConfig $config, string $ipAddress)
7171
{
7272
parent::__construct($config, $ipAddress);
7373

74+
$this->setSavePath();
75+
76+
if ($this->matchIP === true) {
77+
$this->keyPrefix .= $this->ipAddress . ':';
78+
}
79+
80+
$this->sessionExpiration = empty($config->sessionExpiration)
81+
? (int) ini_get('session.gc_maxlifetime')
82+
: (int) $config->sessionExpiration;
83+
}
84+
85+
protected function setSavePath(): void
86+
{
7487
if (empty($this->savePath)) {
7588
throw SessionException::forEmptySavepath();
7689
}
@@ -92,14 +105,6 @@ public function __construct(AppConfig $config, string $ipAddress)
92105
} else {
93106
throw SessionException::forInvalidSavePathFormat($this->savePath);
94107
}
95-
96-
if ($this->matchIP === true) {
97-
$this->keyPrefix .= $this->ipAddress . ':';
98-
}
99-
100-
$this->sessionExpiration = empty($config->sessionExpiration)
101-
? (int) ini_get('session.gc_maxlifetime')
102-
: (int) $config->sessionExpiration;
103108
}
104109

105110
/**

0 commit comments

Comments
 (0)