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

Static Public Member Functions

static get (RequestInterface $request, $name, $value=null)
 
static set (RequestInterface $request, Cookie $cookie)
 
static modify (RequestInterface $request, $name, $modify)
 
static remove (RequestInterface $request, $name)
 

Detailed Description

Definition at line 8 of file FigRequestCookies.php.

Member Function Documentation

◆ get()

static Dflydev\FigCookies\FigRequestCookies::get ( RequestInterface  $request,
  $name,
  $value = null 
)
static
Parameters
RequestInterface$request
string$name
string | null$value
Returns
Cookie

Definition at line 17 of file FigRequestCookies.php.

References Dflydev\FigCookies\Cookie\create(), and Dflydev\FigCookies\Cookies\fromRequest().

Referenced by Dflydev\FigCookies\FigRequestCookiesTest\it_gets_cookies().

18  {
19  $cookies = Cookies::fromRequest($request);
20  if ($cookies->has($name)) {
21  return $cookies->get($name);
22  }
23 
24  return Cookie::create($name, $value);
25  }
static create($name, $value=null)
Create a Cookie.
Definition: Cookie.php:73
foreach($paths as $path) $request
Definition: asyncclient.php:32
static fromRequest(RequestInterface $request)
Create Cookies from a Request.
Definition: Cookies.php:121
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modify()

static Dflydev\FigCookies\FigRequestCookies::modify ( RequestInterface  $request,
  $name,
  $modify 
)
static
Parameters
RequestInterface$request
string$name
callable$modify
Returns
RequestInterface

Definition at line 48 of file FigRequestCookies.php.

References Dflydev\FigCookies\Cookie\create(), and Dflydev\FigCookies\Cookies\fromRequest().

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

49  {
50  if (! is_callable($modify)) {
51  throw new InvalidArgumentException('$modify must be callable.');
52  }
53 
54  $cookies = Cookies::fromRequest($request);
55  $cookie = $modify($cookies->has($name)
56  ? $cookies->get($name)
58  );
59 
60  return $cookies
61  ->with($cookie)
62  ->renderIntoCookieHeader($request)
63  ;
64  }
static create($name, $value=null)
Create a Cookie.
Definition: Cookie.php:73
foreach($paths as $path) $request
Definition: asyncclient.php:32
static fromRequest(RequestInterface $request)
Create Cookies from a Request.
Definition: Cookies.php:121
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove()

static Dflydev\FigCookies\FigRequestCookies::remove ( RequestInterface  $request,
  $name 
)
static
Parameters
RequestInterface$request
string$name
Returns
RequestInterface

Definition at line 72 of file FigRequestCookies.php.

References Dflydev\FigCookies\Cookies\fromRequest().

Referenced by Dflydev\FigCookies\FigRequestCookiesTest\it_removes_cookies().

73  {
75  ->without($name)
76  ->renderIntoCookieHeader($request)
77  ;
78  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
static fromRequest(RequestInterface $request)
Create Cookies from a Request.
Definition: Cookies.php:121
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

static Dflydev\FigCookies\FigRequestCookies::set ( RequestInterface  $request,
Cookie  $cookie 
)
static
Parameters
RequestInterface$request
Cookie$cookie
Returns
RequestInterface

Definition at line 33 of file FigRequestCookies.php.

References Dflydev\FigCookies\Cookies\fromRequest().

Referenced by Dflydev\FigCookies\FigRequestCookiesTest\it_sets_cookies().

34  {
36  ->with($cookie)
37  ->renderIntoCookieHeader($request)
38  ;
39  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
static fromRequest(RequestInterface $request)
Create Cookies from a Request.
Definition: Cookies.php:121
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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