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

Public Member Functions

 __construct (array $cookies=[])
 
 has ($name)
 
 get ($name)
 
 getAll ()
 
 with (Cookie $cookie)
 
 without ($name)
 
 renderIntoCookieHeader (RequestInterface $request)
 Render Cookies into a Request. More...
 

Static Public Member Functions

static fromCookieString ($string)
 Create Cookies from a Cookie header value string. More...
 
static fromRequest (RequestInterface $request)
 Create Cookies from a Request. More...
 

Data Fields

const COOKIE_HEADER = 'Cookie'
 The name of the Cookie header. More...
 

Private Attributes

 $cookies = []
 

Detailed Description

Definition at line 7 of file Cookies.php.

Constructor & Destructor Documentation

◆ __construct()

Dflydev\FigCookies\Cookies::__construct ( array  $cookies = [])
Parameters
Cookie[]$cookies

Definition at line 22 of file Cookies.php.

References Dflydev\FigCookies\Cookies\$cookies.

23  {
24  foreach ($cookies as $cookie) {
25  $this->cookies[$cookie->getName()] = $cookie;
26  }
27  }

Member Function Documentation

◆ fromCookieString()

static Dflydev\FigCookies\Cookies::fromCookieString (   $string)
static

Create Cookies from a Cookie header value string.

Parameters
$string
Returns
static

Definition at line 110 of file Cookies.php.

References Dflydev\FigCookies\Cookie\listFromCookieString().

Referenced by Dflydev\FigCookies\CookiesTest\it_creates_from_cookie_string(), Dflydev\FigCookies\CookiesTest\it_gets_cookie_by_name(), Dflydev\FigCookies\CookiesTest\it_knows_which_cookies_are_available(), and Dflydev\FigCookies\CookiesTest\it_renders_added_and_removed_cookies_header().

111  {
112  return new static(Cookie::listFromCookieString($string));
113  }
static listFromCookieString($string)
Create a list of Cookies from a Cookie header value string.
Definition: Cookie.php:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromRequest()

static Dflydev\FigCookies\Cookies::fromRequest ( RequestInterface  $request)
static

Create Cookies from a Request.

Parameters
RequestInterface$request
Returns
Cookies

Definition at line 121 of file Cookies.php.

References Psr\Http\Message\MessageInterface\getHeaderLine().

Referenced by Dflydev\FigCookies\FigRequestCookies\get(), Dflydev\FigCookies\CookiesTest\it_creates_from_request(), Dflydev\FigCookies\CookiesTest\it_gets_and_updates_cookie_value_on_request(), Dflydev\FigCookies\CookiesTest\it_gets_cookie_value_from_request(), Dflydev\FigCookies\FigRequestCookies\modify(), Dflydev\FigCookies\FigRequestCookies\remove(), and Dflydev\FigCookies\FigRequestCookies\set().

122  {
123  $cookieString = $request->getHeaderLine(static::COOKIE_HEADER);
124 
125  return static::fromCookieString($cookieString);
126  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

Dflydev\FigCookies\Cookies::get (   $name)
Parameters
$name
Returns
Cookie|null

Definition at line 42 of file Cookies.php.

References $name, and Dflydev\FigCookies\Cookies\has().

43  {
44  if (! $this->has($name)) {
45  return null;
46  }
47 
48  return $this->cookies[$name];
49  }
+ Here is the call graph for this function:

◆ getAll()

Dflydev\FigCookies\Cookies::getAll ( )
Returns
Cookie[]

Definition at line 54 of file Cookies.php.

55  {
56  return array_values($this->cookies);
57  }

◆ has()

Dflydev\FigCookies\Cookies::has (   $name)
Parameters
$name
Returns
bool

Definition at line 33 of file Cookies.php.

References $name.

Referenced by Dflydev\FigCookies\Cookies\get().

34  {
35  return isset($this->cookies[$name]);
36  }
+ Here is the caller graph for this function:

◆ renderIntoCookieHeader()

Dflydev\FigCookies\Cookies::renderIntoCookieHeader ( RequestInterface  $request)

Render Cookies into a Request.

Parameters
RequestInterface$request
Returns
RequestInterface

Definition at line 95 of file Cookies.php.

References $request, and Psr\Http\Message\MessageInterface\withHeader().

96  {
97  $cookieString = implode('; ', $this->cookies);
98 
99  $request = $request->withHeader(static::COOKIE_HEADER, $cookieString);
100 
101  return $request;
102  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
+ Here is the call graph for this function:

◆ with()

Dflydev\FigCookies\Cookies::with ( Cookie  $cookie)
Parameters
Cookie$cookie
Returns
Cookies

Definition at line 63 of file Cookies.php.

References Dflydev\FigCookies\Cookie\getName().

64  {
65  $clone = clone($this);
66 
67  $clone->cookies[$cookie->getName()] = $cookie;
68 
69  return $clone;
70  }
+ Here is the call graph for this function:

◆ without()

Dflydev\FigCookies\Cookies::without (   $name)
Parameters
$name
Returns
Cookies

Definition at line 76 of file Cookies.php.

References $name.

77  {
78  $clone = clone($this);
79 
80  if (! $clone->has($name)) {
81  return $clone;
82  }
83 
84  unset($clone->cookies[$name]);
85 
86  return $clone;
87  }

Field Documentation

◆ $cookies

Dflydev\FigCookies\Cookies::$cookies = []
private

Definition at line 17 of file Cookies.php.

Referenced by Dflydev\FigCookies\Cookies\__construct().

◆ COOKIE_HEADER


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