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