ILIAS  release_7 Revision v7.30-3-g800a261c036
CookieWrapper.php
Go to the documentation of this file.
1<?php
2
3namespace ILIAS\HTTP\Cookies;
4
5use Dflydev\FigCookies\SetCookie;
6
17class 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}
An exception for terminatinating execution or to throw for unit testing.
withHttpOnly(bool $httpOnly=null)
@inheritDoc
withPath(string $path=null)
@inheritDoc
withExpires($expires=null)
@inheritDoc
withMaxAge(int $maxAge=null)
@inheritDoc
$cookie
Underlying implementation.
withValue(string $value=null)
@inheritDoc
withDomain(string $domain=null)
@inheritDoc
getImplementation()
Returns the underlying implementation.
__construct(SetCookie $cookie)
CookieFacade constructor.
withSecure(bool $secure=null)
@inheritDoc
withMaxAge(int $maxAge=null)
Maximal life time of the cookie in seconds.
withPath(string $path=null)
Sets the cookie path.
withValue(string $value=null)
Sets the cookie value.
withSecure(bool $secure=null)
Sets if the cookie is a secure cookie or not.
withHttpOnly(bool $httpOnly=null)
Sets if the cookie is http only.
withExpires($expires=null)
Sets the expiration date of the cookie.
expire()
Expire the cookie.
withDomain(string $domain=null)
Sets the domain name for the cookie.
Class CookieJarWrapperTest.
Definition: Cookie.php:3
Class ChatMainBarProvider \MainMenu\Provider.