| Total Complexity | 12 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Session { |
||
| 9 | |||
| 10 | private static $autoSave = true; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Adiciona o alerta na sessão |
||
| 14 | * @param Alert $alert |
||
| 15 | */ |
||
| 16 | public static function addAlert(Alert $alert) { |
||
| 17 | if (static::$autoSave) { |
||
|
|
|||
| 18 | $_SESSION['alerts'][] = $alert; |
||
| 19 | } |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Liga/Desliga o salvamento automático de alertas na sessão |
||
| 24 | * @param boolean $mode |
||
| 25 | */ |
||
| 26 | public static function setAutoSave($mode = true) { |
||
| 27 | static::$autoSave = $mode; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Mostra os alertas criados, podendo filtrar por $type e/ou $group |
||
| 32 | * Removendo-os da sessão |
||
| 33 | * @param string $type |
||
| 34 | * @param string $group |
||
| 35 | */ |
||
| 36 | public static function showAlerts($type = '', $group = '') { |
||
| 37 | foreach (static::getAlerts($type, $group) as $i => $alert) { |
||
| 38 | $alert->load(); |
||
| 39 | unset($_SESSION['alerts'][$i]); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Retorna alertas criados, podendo filtrar por $type e/ou $group |
||
| 45 | * @param string $type |
||
| 46 | * @param string $group |
||
| 47 | * @return Alert[] |
||
| 48 | */ |
||
| 49 | public static function getAlerts($type = '', $group = '') { |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Remove todos os alertas da sessão |
||
| 61 | */ |
||
| 62 | public static function clearAlerts() { |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Retorna TRUE se a sessão possui algum alerta |
||
| 68 | * @return boolean |
||
| 69 | */ |
||
| 70 | public static function hasAlert() { |
||
| 75 |