@@ -36,10 +36,15 @@ class Session
3636 */
3737 protected $ namespace = 'bluz ' ;
3838
39+ /**
40+ * @var string Session handler name
41+ */
42+ protected $ adapter = 'files ' ;
43+
3944 /**
4045 * @var SessionHandlerInterface Session save handler
4146 */
42- protected $ adapter ;
47+ protected $ sessionHandler ;
4348
4449 /**
4550 * Attempt to set the session name
@@ -197,7 +202,7 @@ public function start(): bool
197202 return true ;
198203 }
199204
200- if ($ this ->initAdapter ()) {
205+ if ($ this ->init ()) {
201206 return session_start ();
202207 }
203208
@@ -225,23 +230,23 @@ public function destroy(): void
225230 }
226231
227232 /**
228- * Set session save handler object
233+ * Set session handler name
229234 *
230- * @param SessionHandlerInterface| string $saveHandler
235+ * @param string $adapter
231236 *
232237 * @return void
233238 */
234- public function setAdapter ($ saveHandler ): void
239+ public function setAdapter (string $ adapter ): void
235240 {
236- $ this ->adapter = $ saveHandler ;
241+ $ this ->adapter = $ adapter ;
237242 }
238243
239244 /**
240- * Get SaveHandler Object
245+ * Get session handler name
241246 *
242- * @return SessionHandlerInterface
247+ * @return string
243248 */
244- public function getAdapter (): SessionHandlerInterface
249+ public function getAdapter (): string
245250 {
246251 return $ this ->adapter ;
247252 }
@@ -255,16 +260,16 @@ public function getAdapter(): SessionHandlerInterface
255260 * @return bool
256261 * @throws ComponentException
257262 */
258- protected function initAdapter (): bool
263+ protected function init (): bool
259264 {
260- if (null === $ this -> adapter || 'files ' === $ this ->adapter ) {
265+ if ('files ' === $ this ->adapter ) {
261266 // try to apply settings
262267 if ($ settings = $ this ->getOption ('settings ' , 'files ' )) {
263268 $ this ->setSavePath ($ settings ['save_path ' ]);
264269 }
265270 return true ;
266271 }
267- if (is_string ( $ this ->adapter ) ) {
272+ if (null === $ this ->sessionHandler ) {
268273 $ adapterClass = '\\Bluz \\Session \\Adapter \\' . ucfirst ($ this ->adapter );
269274 if (!class_exists ($ adapterClass ) || !is_subclass_of ($ adapterClass , SessionHandlerInterface::class)) {
270275 throw new ComponentException ("Class for session adapter ` {$ this ->adapter }` not found " );
0 commit comments