Security update to Drupal 8.4.6
[yaffs-website] / vendor / jcalderonzumba / gastonjs / src / Cookie.php
1 <?php
2
3 namespace Zumba\GastonJS;
4
5 /**
6  * Class Cookie
7  * @package Zumba\GastonJS
8  */
9 class Cookie {
10   /** @var  array */
11   protected $attributes;
12
13   /**
14    * @param $attributes
15    */
16   public function __construct($attributes) {
17     $this->attributes = $attributes;
18   }
19
20   /**
21    * Returns the cookie name
22    * @return string
23    */
24   public function getName() {
25     return $this->attributes['name'];
26   }
27
28   /**
29    * Returns the cookie value
30    * @return string
31    */
32   public function getValue() {
33     return urldecode($this->attributes['value']);
34   }
35
36   /**
37    * Returns the cookie domain
38    * @return string
39    */
40   public function getDomain() {
41     return $this->attributes['domain'];
42   }
43
44   /**
45    * Returns the path were the cookie is valid
46    * @return string
47    */
48   public function getPath() {
49     return $this->attributes['path'];
50   }
51
52   /**
53    * Is a secure cookie?
54    * @return bool
55    */
56   public function isSecure() {
57     return isset($this->attributes['secure']);
58   }
59
60   /**
61    * Is http only cookie?
62    * @return bool
63    */
64   public function isHttpOnly() {
65     return isset($this->attributes['httponly']);
66   }
67
68   /**
69    * Returns cookie expiration time
70    * @return mixed
71    */
72   public function getExpirationTime() {
73     //TODO: return a \DateTime object
74     if (isset($this->attributes['expiry'])) {
75       return $this->attributes['expiry'];
76     }
77     return null;
78   }
79 }