| 1 | <?php |
||
| 23 | class Session implements KeyValuePair, Regeneratable |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * Sets the value |
||
| 27 | * |
||
| 28 | * @param string $key The key in which to store the value |
||
| 29 | * @param mixed $value The value to store |
||
| 30 | * |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | 3 | public function set($key, $value) |
|
| 37 | |||
| 38 | /** |
||
| 39 | * Gets a value from the session superglobal |
||
| 40 | * |
||
| 41 | * @param string $key The key of which to retrieve the value |
||
| 42 | * |
||
| 43 | * @return mixed The value |
||
| 44 | * @throws \OpCacheGUI\Storage\InvalidKeyException When the key is not found |
||
| 45 | */ |
||
| 46 | 2 | public function get($key) |
|
| 54 | |||
| 55 | /** |
||
| 56 | * Check whether the supplied key is valid (i.e. does exist in the session superglobal) |
||
| 57 | * |
||
| 58 | * @param string $key The key to check |
||
| 59 | * |
||
| 60 | * @return boolean Whether the supplied key is valid |
||
| 61 | */ |
||
| 62 | 4 | public function isKeyValid($key) |
|
| 70 | |||
| 71 | /** |
||
| 72 | * Regenerates a new session id and initializes the session superglobal |
||
| 73 | * |
||
| 74 | * @codeCoverageIgnore |
||
| 75 | */ |
||
| 76 | public function regenerate() |
||
| 81 | } |
||
| 82 |
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: