1 | <?php |
||
21 | class Session |
||
22 | { |
||
23 | /** |
||
24 | * @param array $options |
||
25 | * @param int $timeout |
||
26 | */ |
||
27 | 15 | public function __construct($options, $timeout = 3600) |
|
40 | |||
41 | 4 | public function close() |
|
45 | |||
46 | /** |
||
47 | * @param User $user |
||
48 | */ |
||
49 | 4 | public function setUser(User $user) |
|
53 | |||
54 | /** |
||
55 | * @return User|false |
||
56 | */ |
||
57 | 15 | public function getUser() |
|
61 | |||
62 | /** |
||
63 | * @param string $key |
||
64 | * @param mixed $value |
||
65 | */ |
||
66 | 15 | public function set($key, $value) |
|
70 | |||
71 | /** |
||
72 | * @param string $key |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | 15 | public function has($key) |
|
80 | |||
81 | /** |
||
82 | * @param string $key |
||
83 | * @param mixed $default |
||
84 | */ |
||
85 | 15 | public function get($key, $default = false) |
|
93 | } |
||
94 |
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: