| Total Complexity | 7 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 15.38% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class UCookie { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Sends a cookie |
||
| 14 | * @param string $name the name of the cookie |
||
| 15 | * @param string $value The value of the cookie. |
||
| 16 | * @param int $duration default : 1 day |
||
| 17 | * @param string $path default : / the cookie will be available within the entire domain |
||
| 18 | */ |
||
| 19 | public static function set($name, $value, $duration=60*60*24, $path="/") { |
||
| 20 | \setcookie($name, $value, \time() + $duration, $path); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Returns the Cookie with the name $name |
||
| 25 | * @param string $name |
||
| 26 | * @param string $default |
||
| 27 | * @return null|string |
||
| 28 | */ |
||
| 29 | 1 | public static function get($name, $default=null) { |
|
| 30 | 1 | return isset($_COOKIE[$name]) ? $_COOKIE[$name] : $default; |
|
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Removes the cookie with the name $name |
||
| 35 | * @param string $name |
||
| 36 | * @param $path |
||
| 37 | */ |
||
| 38 | public static function delete($name, $path="/") { |
||
| 39 | if(isset($_COOKIE[$name])){ |
||
| 40 | unset($_COOKIE[$name]); |
||
| 41 | } |
||
| 42 | \setcookie($name, "", \time() - 3600, $path); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Deletes all cookies |
||
| 47 | */ |
||
| 48 | public function deleteAll($path="/") { |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 |