| Total Complexity | 13 |
| Total Lines | 70 |
| Duplicated Lines | 0 % |
| Coverage | 54.05% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 6 | class Session extends Service implements Interfaces\ISession |
||
| 7 | { |
||
| 8 | protected $parametersList = ['type']; |
||
| 9 | private static $container; |
||
| 10 | |||
| 11 | |||
| 12 | 3 | protected function init() |
|
| 13 | { |
||
| 14 | 3 | if (self::$container === null) { |
|
| 15 | 2 | switch ($this->type) { |
|
|
|
|||
| 16 | 2 | case 'native': |
|
| 17 | 1 | self::$container = Suricate::SessionNative(true); |
|
| 18 | 1 | break; |
|
| 19 | 1 | case 'cookie': |
|
| 20 | self::$container = Suricate::SessionCookie(true); |
||
| 21 | break; |
||
| 22 | 1 | case 'memcache': |
|
| 23 | self::$container = Suricate::SessionMemcache(true); |
||
| 24 | break; |
||
| 25 | 1 | case 'none': |
|
| 26 | break; |
||
| 27 | default: |
||
| 28 | 1 | throw new Exception("Unknown session type " . $this->type); |
|
| 29 | } |
||
| 30 | } |
||
| 31 | 2 | } |
|
| 32 | |||
| 33 | /** |
||
| 34 | * Get instance of session driver used |
||
| 35 | * @return Sessiondriver instance |
||
| 36 | */ |
||
| 37 | public function getInstance() |
||
| 41 | } |
||
| 42 | |||
| 43 | public function getId() |
||
| 44 | { |
||
| 45 | $this->init(); |
||
| 46 | return self::$container->getId(); |
||
| 47 | } |
||
| 48 | public function regenerate() |
||
| 52 | } |
||
| 53 | |||
| 54 | 3 | public function read($key) |
|
| 55 | { |
||
| 56 | 3 | $this->init(); |
|
| 57 | 2 | return self::$container->read($key); |
|
| 58 | } |
||
| 59 | |||
| 60 | 2 | public function write($key, $data) |
|
| 61 | { |
||
| 62 | 2 | $this->init(); |
|
| 63 | 2 | return self::$container->write($key, $data); |
|
| 64 | } |
||
| 65 | |||
| 66 | 2 | public function destroy($key) |
|
| 67 | { |
||
| 68 | 2 | $this->init(); |
|
| 69 | 2 | return self::$container->destroy($key); |
|
| 70 | } |
||
| 71 | |||
| 72 | public function close() |
||
| 76 | } |
||
| 77 | } |
||
| 78 |