From 4c892722dfc5a66d67bc5d82777f3a9f9acb2819 Mon Sep 17 00:00:00 2001 From: Nicholas <47761650+omatamix@users.noreply.github.com> Date: Sat, 27 Nov 2021 22:03:25 -0600 Subject: [PATCH 01/10] Create DatabaseSessionHandler.php --- src/DatabaseSessionHandler.php | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/DatabaseSessionHandler.php diff --git a/src/DatabaseSessionHandler.php b/src/DatabaseSessionHandler.php new file mode 100644 index 0000000..cfffbec --- /dev/null +++ b/src/DatabaseSessionHandler.php @@ -0,0 +1,36 @@ + Date: Sat, 27 Nov 2021 22:04:00 -0600 Subject: [PATCH 02/10] Rename src/DatabaseSessionHandler.php to src/Handlers/DatabaseSessionHandler.php --- src/{ => Handlers}/DatabaseSessionHandler.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{ => Handlers}/DatabaseSessionHandler.php (100%) diff --git a/src/DatabaseSessionHandler.php b/src/Handlers/DatabaseSessionHandler.php similarity index 100% rename from src/DatabaseSessionHandler.php rename to src/Handlers/DatabaseSessionHandler.php From b6aab280416e302dd1c61cf653720ea23d51fa00 Mon Sep 17 00:00:00 2001 From: Nicholas <47761650+omatamix@users.noreply.github.com> Date: Sat, 27 Nov 2021 22:08:24 -0600 Subject: [PATCH 03/10] Create CacheSessionHandler.php --- src/Handlers/CacheSessionHandler.php | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Handlers/CacheSessionHandler.php diff --git a/src/Handlers/CacheSessionHandler.php b/src/Handlers/CacheSessionHandler.php new file mode 100644 index 0000000..8203a77 --- /dev/null +++ b/src/Handlers/CacheSessionHandler.php @@ -0,0 +1,36 @@ + Date: Sat, 27 Nov 2021 22:08:54 -0600 Subject: [PATCH 04/10] Create BlackholeSessionHandler.php --- src/Handlers/BlackholeSessionHandler.php | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Handlers/BlackholeSessionHandler.php diff --git a/src/Handlers/BlackholeSessionHandler.php b/src/Handlers/BlackholeSessionHandler.php new file mode 100644 index 0000000..0b08da2 --- /dev/null +++ b/src/Handlers/BlackholeSessionHandler.php @@ -0,0 +1,36 @@ + Date: Sat, 27 Nov 2021 22:09:45 -0600 Subject: [PATCH 05/10] Create FilesystemSessionHandler.php --- src/Handlers/FilesystemSessionHandler.php | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Handlers/FilesystemSessionHandler.php diff --git a/src/Handlers/FilesystemSessionHandler.php b/src/Handlers/FilesystemSessionHandler.php new file mode 100644 index 0000000..051b148 --- /dev/null +++ b/src/Handlers/FilesystemSessionHandler.php @@ -0,0 +1,36 @@ + Date: Sat, 27 Nov 2021 22:10:35 -0600 Subject: [PATCH 06/10] Create EncryptedSessionHandler.php --- src/Handlers/EncryptedSessionHandler.php | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Handlers/EncryptedSessionHandler.php diff --git a/src/Handlers/EncryptedSessionHandler.php b/src/Handlers/EncryptedSessionHandler.php new file mode 100644 index 0000000..598c396 --- /dev/null +++ b/src/Handlers/EncryptedSessionHandler.php @@ -0,0 +1,36 @@ + Date: Sat, 27 Nov 2021 22:48:18 -0600 Subject: [PATCH 07/10] Update SessionMiddleware.php --- src/SessionMiddleware.php | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/SessionMiddleware.php b/src/SessionMiddleware.php index 8b13789..71c2f17 100644 --- a/src/SessionMiddleware.php +++ b/src/SessionMiddleware.php @@ -1 +1,52 @@ + Date: Sat, 27 Nov 2021 23:04:24 -0600 Subject: [PATCH 08/10] Update StaticSessionManager.php --- src/StaticSessionManager.php | 146 +++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/src/StaticSessionManager.php b/src/StaticSessionManager.php index 8b13789..bd43f20 100644 --- a/src/StaticSessionManager.php +++ b/src/StaticSessionManager.php @@ -1 +1,147 @@ +start(); + } + + /** + * Stop a session and destroys all data. + * + * @return bool Returns true on success or false on failure. + */ + public function stop(): bool + { + return session()->stop(); + } + + /** + * Check to see if a session already exists. + * + * @return bool Returns true if one exists and false if not. + */ + public static function exists(): bool + { + return session()->exists(); + } + + /** + * Stop a session and destroys all data. + * + * @return bool Returns true on success or false on failure. + */ + public static function invalidate(): bool + { + return session()->invalidate(); + } + + /** + * Checks whether a value for the specified key exists in the session. + * + * @param string $key The key to check. + * + * @return bool Returns true if the key was found and false if not. + */ + public static function has(string $key): bool + { + return session()->has($key); + } + + /** + * Returns the requested value from the session or, if not found, the + * specified default value. + * + * @param string $key The key to retrieve the value for. + * @param mixed $defaultValue The default value to return if the + * requested value cannot be found. + * + * @return mixed Returns the requested value or the default + * value. + */ + public static function get(string $key, $defaultValue = null): mixed + { + return session()->get($key, $defaultValue); + } + + /** + * Returns the requested value and removes it from the session. + * + * This is identical to calling `get` first and then `remove` for the same + * key. + * + * @param string $key The key to retrieve and remove the value for. + * @param mixed $defaultValue The default value to return if the requested + * value cannot be found. + * + * @return mixed The requested value or the default value. + */ + public static function flash(string $key, $defaultValue = null): mixed + { + return session()->flash($key, $defaultValue); + } + + /** + * Sets the value for the specified key to the given value. + * + * Any data that already exists for the specified key will be overwritten. + * + * @param string $key The key to set the value for. + * @param mixed $value The value to set. + * + * @return void Returns nothing. + */ + public static function put(string $key, $value): void + { + return session()->put($key, $value); + } + + /** + * Removes the value for the specified key from the session. + * + * @param string $key The key to remove the value for. + * + * @return void Returns nothing. + */ + public function delete(string $key): void + { + return session()->delete($key); + } +} From 86010e7d8241f38e77845ff886a86aa1dd455b3c Mon Sep 17 00:00:00 2001 From: Nicholas <47761650+omatamix@users.noreply.github.com> Date: Sat, 27 Nov 2021 23:11:51 -0600 Subject: [PATCH 09/10] Create bootstrap.php --- bootstrap.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bootstrap.php diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..71a8179 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,34 @@ + Date: Sat, 27 Nov 2021 23:13:20 -0600 Subject: [PATCH 10/10] Update bootstrap.php --- bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bootstrap.php b/bootstrap.php index 71a8179..b4da322 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -26,6 +26,10 @@ * SOFTWARE. */ +if (!function_exists('app')) { + throw new RuntimeException('Unable to locate a container.'); +} + if (!function_exists('session')) { function session(): SessionManager {