1 | <?php |
||
20 | abstract class Driver implements SessionDriverInterface |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var string Session prefix on key names |
||
25 | */ |
||
26 | protected $prefix; |
||
27 | |||
28 | /** |
||
29 | * Driver constructor. |
||
30 | * |
||
31 | * The $options parameter is an associative array where key will be matched |
||
32 | * with the driver property and if property exists the correspondent value |
||
33 | * will be assigned. |
||
34 | * |
||
35 | * @param array $options |
||
36 | */ |
||
37 | 14 | public function __construct(array $options = []) |
|
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 2 | public function set($key, $value) |
|
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | 4 | public function get($key, $default = null) |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 2 | public function erase($key) |
|
78 | |||
79 | /** |
||
80 | * Sets the prefix for session key names |
||
81 | * |
||
82 | * @param string $prefix |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | 2 | public function setPrefix($prefix) |
|
91 | } |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: