| 1 | <?php |
||
| 15 | class FlashMessages |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Reset the messages |
||
| 19 | */ |
||
| 20 | public static function reset() |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Set flash message |
||
| 27 | * Add a message to the array |
||
| 28 | * @note: Should we restrict/limit types to only the 4 listed in the header? |
||
| 29 | * @param string $message |
||
| 30 | * @param string $type |
||
| 31 | */ |
||
| 32 | public static function set($message, $type = 'danger') |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get flash messages |
||
| 44 | * @return array $messages |
||
| 45 | */ |
||
| 46 | public static function get() |
||
| 55 | |||
| 56 | } |
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: