| 1 | <?php |
||
| 18 | class FlashData |
||
| 19 | { |
||
| 20 | |||
| 21 | protected $previous = []; |
||
| 22 | protected $next = []; |
||
| 23 | |||
| 24 | protected $session_var = 'flash-data'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * FlashData constructor. |
||
| 28 | */ |
||
| 29 | public function __construct() |
||
| 33 | |||
| 34 | public function read() |
||
| 44 | |||
| 45 | public function has($var) |
||
| 49 | |||
| 50 | public function get($var) |
||
| 54 | |||
| 55 | 1 | public function add($var, $value) |
|
| 60 | |||
| 61 | 1 | protected function write() |
|
| 65 | |||
| 66 | public function remove($var) |
||
| 71 | |||
| 72 | protected function clear() |
||
| 76 | } |
||
| 77 |
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: