Skip to content

Commit 3c5b48d

Browse files
refactor: rename session creation method and add session existence check
1 parent bde1df5 commit 3c5b48d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Session/Session.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function __construct(
4040
}
4141

4242
/**
43-
* Create a session instance from handler or return null if session doesn't exist
43+
* Retrieve an existing session instance from handler or return null if session doesn't exist
4444
*/
45-
public static function make(string $id, SessionHandlerInterface $handler): ?SessionInterface
45+
public static function retrieve(string $id, SessionHandlerInterface $handler): ?SessionInterface
4646
{
4747
$sessionData = $handler->read($id);
4848

src/Session/SessionManager.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ public function createSession(string $sessionId): SessionInterface
9898
*/
9999
public function getSession(string $sessionId): ?SessionInterface
100100
{
101-
return Session::make($sessionId, $this->handler);
101+
return Session::retrieve($sessionId, $this->handler);
102+
}
103+
104+
public function hasSession(string $sessionId): bool
105+
{
106+
return $this->getSession($sessionId) !== null;
102107
}
103108

104109
/**

0 commit comments

Comments
 (0)