ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
CookieWrapper.php
Go to the documentation of this file.
1 <?php
2 
3 namespace ILIAS\HTTP\Cookies;
4 
6 
17 class CookieWrapper implements Cookie
18 {
19 
25  private $cookie;
26 
27 
33  public function __construct(SetCookie $cookie)
34  {
35  $this->cookie = $cookie;
36  }
37 
38 
42  public function getName() : string
43  {
44  return $this->cookie->getName();
45  }
46 
47 
51  public function getValue() : ?string
52  {
53  return $this->cookie->getValue();
54  }
55 
56 
60  public function getExpires() : int
61  {
62  return $this->cookie->getExpires();
63  }
64 
65 
69  public function getMaxAge() : int
70  {
71  return $this->cookie->getMaxAge();
72  }
73 
74 
78  public function getPath() : ?string
79  {
80  return $this->cookie->getPath();
81  }
82 
83 
87  public function getDomain() : ?string
88  {
89  return $this->cookie->getDomain();
90  }
91 
92 
96  public function getSecure() : bool
97  {
98  return $this->cookie->getSecure();
99  }
100 
101 
105  public function getHttpOnly() : bool
106  {
107  return $this->cookie->getHttpOnly();
108  }
109 
110 
114  public function withValue(string $value = null) : \ILIAS\HTTP\Cookies\Cookie
115  {
116  $clone = clone $this;
117  $clone->cookie = $this->cookie->withValue($value);
118 
119  return $clone;
120  }
121 
122 
126  public function withExpires($expires = null) : \ILIAS\HTTP\Cookies\Cookie
127  {
128  $clone = clone $this;
129  $clone->cookie = $this->cookie->withExpires($expires);
130 
131  return $clone;
132  }
133 
134 
138  public function rememberForLongTime() : \ILIAS\HTTP\Cookies\Cookie
139  {
140  $clone = clone $this;
141  $clone->cookie = $this->cookie->rememberForever();
142 
143  return $clone;
144  }
145 
146 
150  public function expire() : \ILIAS\HTTP\Cookies\Cookie
151  {
152  $clone = clone $this;
153  $clone->cookie = $this->cookie->expire();
154 
155  return $clone;
156  }
157 
158 
162  public function withMaxAge(int $maxAge = null) : \ILIAS\HTTP\Cookies\Cookie
163  {
164  $clone = clone $this;
165  $clone->cookie = $this->cookie->withMaxAge($maxAge);
166 
167  return $clone;
168  }
169 
170 
174  public function withPath(string $path = null) : \ILIAS\HTTP\Cookies\Cookie
175  {
176  $clone = clone $this;
177  $clone->cookie = $this->cookie->withPath($path);
178 
179  return $clone;
180  }
181 
182 
186  public function withDomain(string $domain = null) : \ILIAS\HTTP\Cookies\Cookie
187  {
188  $clone = clone $this;
189  $clone->cookie = $this->cookie->withDomain($domain);
190 
191  return $clone;
192  }
193 
194 
198  public function withSecure(bool $secure = null) : \ILIAS\HTTP\Cookies\Cookie
199  {
200  $clone = clone $this;
201  $clone->cookie = $this->cookie->withSecure($secure);
202 
203  return $clone;
204  }
205 
206 
210  public function withHttpOnly(bool $httpOnly = null) : \ILIAS\HTTP\Cookies\Cookie
211  {
212  $clone = clone $this;
213  $clone->cookie = $this->cookie->withHttpOnly($httpOnly);
214 
215  return $clone;
216  }
217 
218 
222  public function __toString() : string
223  {
224  return $this->cookie->__toString();
225  }
226 
227 
235  public function getImplementation()
236  {
237  return $this->cookie;
238  }
239 }
withHttpOnly(bool $httpOnly=null)
Class ChatMainBarProvider .
withMaxAge(int $maxAge=null)
Maximal life time of the cookie in seconds.
withPath(string $path=null)
Sets the cookie path.
withSecure(bool $secure=null)
Sets if the cookie is a secure cookie or not.
expire()
Expire the cookie.
Class CookieJarWrapperTest.
Definition: Cookie.php:3
getImplementation()
Returns the underlying implementation.
withValue(string $value=null)
Sets the cookie value.
withHttpOnly(bool $httpOnly=null)
Sets if the cookie is http only.
withDomain(string $domain=null)
$cookie
Underlying implementation.
withExpires($expires=null)
Sets the expiration date of the cookie.
__construct(SetCookie $cookie)
CookieFacade constructor.
withDomain(string $domain=null)
Sets the domain name for the cookie.