ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Dflydev\FigCookies\SetCookie Class Reference
+ Collaboration diagram for Dflydev\FigCookies\SetCookie:

Public Member Functions

 getName ()
 
 getValue ()
 
 getExpires ()
 
 getMaxAge ()
 
 getPath ()
 
 getDomain ()
 
 getSecure ()
 
 getHttpOnly ()
 
 withValue ($value=null)
 
 withExpires ($expires=null)
 
 rememberForever ()
 
 expire ()
 
 withMaxAge ($maxAge=null)
 
 withPath ($path=null)
 
 withDomain ($domain=null)
 
 withSecure ($secure=null)
 
 withHttpOnly ($httpOnly=null)
 
 __toString ()
 

Static Public Member Functions

static create ($name, $value=null)
 
static createRememberedForever ($name, $value=null)
 
static createExpired ($name)
 

Private Member Functions

 __construct ($name, $value=null)
 
 resolveExpires ($expires=null)
 
 appendFormattedDomainPartIfSet (array $cookieStringParts)
 
 appendFormattedPathPartIfSet (array $cookieStringParts)
 
 appendFormattedExpiresPartIfSet (array $cookieStringParts)
 
 appendFormattedMaxAgePartIfSet (array $cookieStringParts)
 
 appendFormattedSecurePartIfSet (array $cookieStringParts)
 
 appendFormattedHttpOnlyPartIfSet (array $cookieStringParts)
 

Private Attributes

 $name
 
 $value
 
 $expires = 0
 
 $maxAge = 0
 
 $path
 
 $domain
 
 $secure = false
 
 $httpOnly = false
 

Detailed Description

Definition at line 8 of file SetCookie.php.

Constructor & Destructor Documentation

◆ __construct()

Dflydev\FigCookies\SetCookie::__construct (   $name,
  $value = null 
)
private

Definition at line 19 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$name, and Dflydev\FigCookies\SetCookie\$value.

20  {
21  $this->name = $name;
22  $this->value = $value;
23  }

Member Function Documentation

◆ __toString()

Dflydev\FigCookies\SetCookie::__toString ( )

Definition at line 157 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\appendFormattedDomainPartIfSet(), Dflydev\FigCookies\SetCookie\appendFormattedExpiresPartIfSet(), Dflydev\FigCookies\SetCookie\appendFormattedHttpOnlyPartIfSet(), Dflydev\FigCookies\SetCookie\appendFormattedMaxAgePartIfSet(), Dflydev\FigCookies\SetCookie\appendFormattedPathPartIfSet(), and Dflydev\FigCookies\SetCookie\appendFormattedSecurePartIfSet().

158  {
159  $cookieStringParts = [
160  urlencode($this->name).'='.urlencode($this->value),
161  ];
162 
163  $cookieStringParts = $this->appendFormattedDomainPartIfSet($cookieStringParts);
164  $cookieStringParts = $this->appendFormattedPathPartIfSet($cookieStringParts);
165  $cookieStringParts = $this->appendFormattedExpiresPartIfSet($cookieStringParts);
166  $cookieStringParts = $this->appendFormattedMaxAgePartIfSet($cookieStringParts);
167  $cookieStringParts = $this->appendFormattedSecurePartIfSet($cookieStringParts);
168  $cookieStringParts = $this->appendFormattedHttpOnlyPartIfSet($cookieStringParts);
169 
170  return implode('; ', $cookieStringParts);
171  }
appendFormattedMaxAgePartIfSet(array $cookieStringParts)
Definition: SetCookie.php:261
appendFormattedHttpOnlyPartIfSet(array $cookieStringParts)
Definition: SetCookie.php:279
appendFormattedDomainPartIfSet(array $cookieStringParts)
Definition: SetCookie.php:234
appendFormattedPathPartIfSet(array $cookieStringParts)
Definition: SetCookie.php:243
appendFormattedExpiresPartIfSet(array $cookieStringParts)
Definition: SetCookie.php:252
appendFormattedSecurePartIfSet(array $cookieStringParts)
Definition: SetCookie.php:270
+ Here is the call graph for this function:

◆ appendFormattedDomainPartIfSet()

Dflydev\FigCookies\SetCookie::appendFormattedDomainPartIfSet ( array  $cookieStringParts)
private

Definition at line 234 of file SetCookie.php.

Referenced by Dflydev\FigCookies\SetCookie\__toString().

235  {
236  if ($this->domain) {
237  $cookieStringParts[] = sprintf("Domain=%s", $this->domain);
238  }
239 
240  return $cookieStringParts;
241  }
+ Here is the caller graph for this function:

◆ appendFormattedExpiresPartIfSet()

Dflydev\FigCookies\SetCookie::appendFormattedExpiresPartIfSet ( array  $cookieStringParts)
private

Definition at line 252 of file SetCookie.php.

Referenced by Dflydev\FigCookies\SetCookie\__toString().

253  {
254  if ($this->expires) {
255  $cookieStringParts[] = sprintf("Expires=%s", gmdate('D, d M Y H:i:s T', $this->expires));
256  }
257 
258  return $cookieStringParts;
259  }
+ Here is the caller graph for this function:

◆ appendFormattedHttpOnlyPartIfSet()

Dflydev\FigCookies\SetCookie::appendFormattedHttpOnlyPartIfSet ( array  $cookieStringParts)
private

Definition at line 279 of file SetCookie.php.

Referenced by Dflydev\FigCookies\SetCookie\__toString().

280  {
281  if ($this->httpOnly) {
282  $cookieStringParts[] = 'HttpOnly';
283  }
284 
285  return $cookieStringParts;
286  }
+ Here is the caller graph for this function:

◆ appendFormattedMaxAgePartIfSet()

Dflydev\FigCookies\SetCookie::appendFormattedMaxAgePartIfSet ( array  $cookieStringParts)
private

Definition at line 261 of file SetCookie.php.

Referenced by Dflydev\FigCookies\SetCookie\__toString().

262  {
263  if ($this->maxAge) {
264  $cookieStringParts[] = sprintf("Max-Age=%s", $this->maxAge);
265  }
266 
267  return $cookieStringParts;
268  }
+ Here is the caller graph for this function:

◆ appendFormattedPathPartIfSet()

Dflydev\FigCookies\SetCookie::appendFormattedPathPartIfSet ( array  $cookieStringParts)
private

Definition at line 243 of file SetCookie.php.

Referenced by Dflydev\FigCookies\SetCookie\__toString().

244  {
245  if ($this->path) {
246  $cookieStringParts[] = sprintf("Path=%s", $this->path);
247  }
248 
249  return $cookieStringParts;
250  }
+ Here is the caller graph for this function:

◆ appendFormattedSecurePartIfSet()

Dflydev\FigCookies\SetCookie::appendFormattedSecurePartIfSet ( array  $cookieStringParts)
private

Definition at line 270 of file SetCookie.php.

Referenced by Dflydev\FigCookies\SetCookie\__toString().

271  {
272  if ($this->secure) {
273  $cookieStringParts[] = 'Secure';
274  }
275 
276  return $cookieStringParts;
277  }
+ Here is the caller graph for this function:

◆ create()

◆ createExpired()

static Dflydev\FigCookies\SetCookie::createExpired (   $name)
static

◆ createRememberedForever()

static Dflydev\FigCookies\SetCookie::createRememberedForever (   $name,
  $value = null 
)
static

Definition at line 178 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$name, and Dflydev\FigCookies\SetCookie\$value.

Referenced by ILIAS\HTTP\Cookies\CookieFactoryImpl\createRememberedForLongTime(), and Dflydev\FigCookies\SetCookieTest\it_creates_long_living_cookies().

179  {
180  return static::create($name, $value)->rememberForever();
181  }
+ Here is the caller graph for this function:

◆ expire()

Dflydev\FigCookies\SetCookie::expire ( )

Definition at line 107 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\withExpires().

108  {
109  return $this->withExpires(new DateTime('-5 years'));
110  }
withExpires($expires=null)
Definition: SetCookie.php:91
+ Here is the call graph for this function:

◆ getDomain()

Dflydev\FigCookies\SetCookie::getDomain ( )

Definition at line 50 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$domain.

51  {
52  return $this->domain;
53  }

◆ getExpires()

Dflydev\FigCookies\SetCookie::getExpires ( )

Definition at line 35 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$expires.

36  {
37  return $this->expires;
38  }

◆ getHttpOnly()

Dflydev\FigCookies\SetCookie::getHttpOnly ( )

Definition at line 60 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$httpOnly.

61  {
62  return $this->httpOnly;
63  }

◆ getMaxAge()

Dflydev\FigCookies\SetCookie::getMaxAge ( )

Definition at line 40 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$maxAge.

41  {
42  return $this->maxAge;
43  }

◆ getName()

Dflydev\FigCookies\SetCookie::getName ( )

Definition at line 25 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$name.

Referenced by Dflydev\FigCookies\FigResponseCookiesTest\it_modifies_cookies(), and Dflydev\FigCookies\SetCookies\with().

26  {
27  return $this->name;
28  }
+ Here is the caller graph for this function:

◆ getPath()

Dflydev\FigCookies\SetCookie::getPath ( )

Definition at line 45 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$path.

46  {
47  return $this->path;
48  }

◆ getSecure()

Dflydev\FigCookies\SetCookie::getSecure ( )

Definition at line 55 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$secure.

56  {
57  return $this->secure;
58  }

◆ getValue()

Dflydev\FigCookies\SetCookie::getValue ( )

Definition at line 30 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$value.

Referenced by Dflydev\FigCookies\FigCookiesTest\it_encrypts_and_decrypts_cookies().

31  {
32  return $this->value;
33  }
+ Here is the caller graph for this function:

◆ rememberForever()

Dflydev\FigCookies\SetCookie::rememberForever ( )

Definition at line 102 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\withExpires().

103  {
104  return $this->withExpires(new DateTime('+5 years'));
105  }
withExpires($expires=null)
Definition: SetCookie.php:91
+ Here is the call graph for this function:

◆ resolveExpires()

Dflydev\FigCookies\SetCookie::resolveExpires (   $expires = null)
private

Definition at line 74 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$expires.

Referenced by Dflydev\FigCookies\SetCookie\withExpires().

75  {
76  if (is_null($expires)) {
77  return null;
78  }
79 
80  if ($expires instanceof DateTime || $expires instanceof DateTimeInterface) {
81  return $expires->getTimestamp();
82  }
83 
84  if (is_numeric($expires)) {
85  return $expires;
86  }
87 
88  return strtotime($expires);
89  }
+ Here is the caller graph for this function:

◆ withDomain()

Dflydev\FigCookies\SetCookie::withDomain (   $domain = null)

Definition at line 130 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$domain.

131  {
132  $clone = clone($this);
133 
134  $clone->domain = $domain;
135 
136  return $clone;
137  }

◆ withExpires()

Dflydev\FigCookies\SetCookie::withExpires (   $expires = null)

Definition at line 91 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$expires, and Dflydev\FigCookies\SetCookie\resolveExpires().

Referenced by Dflydev\FigCookies\SetCookie\expire(), and Dflydev\FigCookies\SetCookie\rememberForever().

92  {
94 
95  $clone = clone($this);
96 
97  $clone->expires = $expires;
98 
99  return $clone;
100  }
resolveExpires($expires=null)
Definition: SetCookie.php:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withHttpOnly()

Dflydev\FigCookies\SetCookie::withHttpOnly (   $httpOnly = null)

Definition at line 148 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$httpOnly.

149  {
150  $clone = clone($this);
151 
152  $clone->httpOnly = $httpOnly;
153 
154  return $clone;
155  }

◆ withMaxAge()

Dflydev\FigCookies\SetCookie::withMaxAge (   $maxAge = null)

Definition at line 112 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$maxAge.

113  {
114  $clone = clone($this);
115 
116  $clone->maxAge = $maxAge;
117 
118  return $clone;
119  }

◆ withPath()

Dflydev\FigCookies\SetCookie::withPath (   $path = null)

Definition at line 121 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$path.

122  {
123  $clone = clone($this);
124 
125  $clone->path = $path;
126 
127  return $clone;
128  }

◆ withSecure()

Dflydev\FigCookies\SetCookie::withSecure (   $secure = null)

Definition at line 139 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$secure.

140  {
141  $clone = clone($this);
142 
143  $clone->secure = $secure;
144 
145  return $clone;
146  }

◆ withValue()

Dflydev\FigCookies\SetCookie::withValue (   $value = null)

Definition at line 65 of file SetCookie.php.

References Dflydev\FigCookies\SetCookie\$value.

Referenced by Dflydev\FigCookies\FigCookiesTest\it_encrypts_and_decrypts_cookies(), and Dflydev\FigCookies\FigResponseCookiesTest\it_modifies_cookies().

66  {
67  $clone = clone($this);
68 
69  $clone->value = $value;
70 
71  return $clone;
72  }
+ Here is the caller graph for this function:

Field Documentation

◆ $domain

Dflydev\FigCookies\SetCookie::$domain
private

◆ $expires

Dflydev\FigCookies\SetCookie::$expires = 0
private

◆ $httpOnly

Dflydev\FigCookies\SetCookie::$httpOnly = false
private

◆ $maxAge

Dflydev\FigCookies\SetCookie::$maxAge = 0
private

◆ $name

◆ $path

Dflydev\FigCookies\SetCookie::$path
private

◆ $secure

Dflydev\FigCookies\SetCookie::$secure = false
private

◆ $value


The documentation for this class was generated from the following file: