|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Session.php |
| 4 | + * |
| 5 | + * This file is part of Sessions. |
| 6 | + * |
| 7 | + * @author Muhammet ŞAFAK <info@muhammetsafak.com.tr> |
| 8 | + * @copyright Copyright © 2022 Muhammet ŞAFAK |
| 9 | + * @license ./LICENSE MIT |
| 10 | + * @version 1.0 |
| 11 | + * @link https://www.muhammetsafak.com.tr |
| 12 | + */ |
| 13 | + |
| 14 | +declare(strict_types=1); |
| 15 | + |
| 16 | +namespace InitPHP\Sessions\Facede; |
| 17 | + |
| 18 | +use InitPHP\Sessions\Session as SessionInstance; |
| 19 | + |
| 20 | +/** |
| 21 | + * @mixin SessionInstance |
| 22 | + * @method static string getName() |
| 23 | + * @method static SessionInstance setName(string $name) |
| 24 | + * @method static bool isStarted() |
| 25 | + * @method static bool start(array $options = []) |
| 26 | + * @method static bool regenerateId(bool $deleteOldSession = false) |
| 27 | + * @method static string getID() |
| 28 | + * @method static bool setID(string $sessionId) |
| 29 | + * @method static array all() |
| 30 | + * @method static bool destroy() |
| 31 | + * @method static bool flush() |
| 32 | + * @method static bool has(string $key) |
| 33 | + * @method static mixed get(string $key, mixed $default = null) |
| 34 | + * @method static mixed pull(string $key, mixed $default = null) |
| 35 | + * @method static SessionInstance set(string $key, mixed $value, null|int $ttl = null) |
| 36 | + * @method static mixed push(string $key, mixed $value, null|int $ttl = null) |
| 37 | + * @method static SessionInstance setAssoc(array $assoc, null|int $ttl = null) |
| 38 | + * @method static SessionInstance remove(string ...$key) |
| 39 | + */ |
| 40 | +class Session |
| 41 | +{ |
| 42 | + |
| 43 | + /** @var SessionInstance */ |
| 44 | + private static $sessionInstance; |
| 45 | + |
| 46 | + private static function getInstance(): SessionInstance |
| 47 | + { |
| 48 | + if(!isset(self::$sessionInstance)){ |
| 49 | + self::$sessionInstance = new SessionInstance(); |
| 50 | + } |
| 51 | + return self::$sessionInstance; |
| 52 | + } |
| 53 | + |
| 54 | + public function __call($name, $arguments) |
| 55 | + { |
| 56 | + return self::getInstance()->{$name}(...$arguments); |
| 57 | + } |
| 58 | + |
| 59 | + public static function __callStatic($name, $arguments) |
| 60 | + { |
| 61 | + return self::getInstance()->{$name}(...$arguments); |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments