ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CookieWrapper.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\HTTP\Cookies;
20
21use Dflydev\FigCookies\SetCookie;
22use Dflydev\FigCookies\Modifier\SameSite;
23
32class CookieWrapper implements Cookie
33{
37 public function __construct(private SetCookie $cookie)
38 {
39 }
40
44 public function getName(): string
45 {
46 return $this->cookie->getName();
47 }
48
52 public function getValue(): ?string
53 {
54 return $this->cookie->getValue();
55 }
56
60 public function getExpires(): int
61 {
62 return $this->cookie->getExpires();
63 }
64
68 public function getMaxAge(): int
69 {
70 return $this->cookie->getMaxAge();
71 }
72
76 public function getPath(): ?string
77 {
78 return $this->cookie->getPath();
79 }
80
84 public function getDomain(): ?string
85 {
86 return $this->cookie->getDomain();
87 }
88
92 public function getSecure(): bool
93 {
94 return $this->cookie->getSecure();
95 }
96
100 public function getHttpOnly(): bool
101 {
102 return $this->cookie->getHttpOnly();
103 }
104
105 public function getSamesite(): ?string
106 {
107 $samesite = $this->cookie->getSameSite();
108 return is_null($samesite) ? null : $samesite->asString();
109 }
110
114 public function withValue(?string $value = null): Cookie
115 {
116 $clone = clone $this;
117 $clone->cookie = $this->cookie->withValue($value);
118
119 return $clone;
120 }
121
125 public function withExpires($expires = null): Cookie
126 {
127 $clone = clone $this;
128 $clone->cookie = $this->cookie->withExpires($expires);
129
130 return $clone;
131 }
132
136 public function rememberForLongTime(): Cookie
137 {
138 $clone = clone $this;
139 $clone->cookie = $this->cookie->rememberForever();
140
141 return $clone;
142 }
143
147 public function expire(): Cookie
148 {
149 $clone = clone $this;
150 $clone->cookie = $this->cookie->expire();
151
152 return $clone;
153 }
154
158 public function withMaxAge(?int $maxAge = null): Cookie
159 {
160 $clone = clone $this;
161 $clone->cookie = $this->cookie->withMaxAge($maxAge);
162
163 return $clone;
164 }
165
169 public function withPath(?string $path = null): Cookie
170 {
171 $clone = clone $this;
172 $clone->cookie = $this->cookie->withPath($path);
173
174 return $clone;
175 }
176
180 public function withDomain(?string $domain = null): Cookie
181 {
182 $clone = clone $this;
183 $clone->cookie = $this->cookie->withDomain($domain);
184
185 return $clone;
186 }
187
191 public function withSecure(?bool $secure = null): Cookie
192 {
193 $clone = clone $this;
194 $clone->cookie = $this->cookie->withSecure($secure);
195
196 return $clone;
197 }
198
202 public function withHttpOnly(?bool $httpOnly = null): Cookie
203 {
204 $clone = clone $this;
205 $clone->cookie = $this->cookie->withHttpOnly($httpOnly);
206
207 return $clone;
208 }
209
210 public function withSamesite(string $sameSite): Cookie
211 {
212 $clone = clone $this;
213 $clone->cookie = $this->cookie->withSameSite(SameSite::fromString($sameSite));
214
215 return $clone;
216 }
217
221 public function __toString(): string
222 {
223 return $this->cookie->__toString();
224 }
225
231 public function getImplementation(): SetCookie
232 {
233 return $this->cookie;
234 }
235}
withExpires($expires=null)
@inheritDoc
withSamesite(string $sameSite)
Sets the samesite attribute.
withDomain(?string $domain=null)
@inheritDoc
withMaxAge(?int $maxAge=null)
@inheritDoc
withValue(?string $value=null)
@inheritDoc
withPath(?string $path=null)
@inheritDoc
withHttpOnly(?bool $httpOnly=null)
@inheritDoc
__construct(private SetCookie $cookie)
CookieFacade constructor.
getImplementation()
Returns the underlying implementation.
withSecure(?bool $secure=null)
@inheritDoc
withPath(?string $path=null)
Sets the cookie path.
withDomain(?string $domain=null)
Sets the domain name for the cookie.
withValue(?string $value=null)
Sets the cookie value.
withExpires($expires=null)
Sets the expiration date of the cookie.
withMaxAge(?int $maxAge=null)
Maximal life time of the cookie in seconds.
withHttpOnly(?bool $httpOnly=null)
Sets if the cookie is http only.
expire()
Expire the cookie.
withSecure(?bool $secure=null)
Sets if the cookie is a secure cookie or not.
$path
Definition: ltiservices.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Cookie.php:19