| Total Complexity | 5 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Cookie implements ICookie |
||
| 8 | { |
||
| 9 | |||
| 10 | protected $cookie; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * instanciate |
||
| 14 | */ |
||
| 15 | public function __construct() |
||
| 16 | { |
||
| 17 | $this->refreshCookie(); |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * get cookie value from cookie name |
||
| 22 | * |
||
| 23 | * @param string $name |
||
| 24 | * @return string |
||
| 25 | */ |
||
| 26 | public function getCookie(string $name): string |
||
| 27 | { |
||
| 28 | return (isset($this->cookie[$name])) ? $this->cookie[$name] : ''; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * set cookie value for cookie name and ttl |
||
| 33 | * |
||
| 34 | * @param string $name |
||
| 35 | * @param string $value |
||
| 36 | * @param integer $ttl |
||
| 37 | * @return Cookie |
||
| 38 | */ |
||
| 39 | public function setCookie(string $name, string $value, int $ttl): Cookie |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * refresh cookie from global |
||
| 47 | * |
||
| 48 | * @return Cookie |
||
| 49 | */ |
||
| 50 | protected function refreshCookie(): Cookie |
||
| 54 | } |
||
| 55 | } |
||
| 56 |