ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
FigRequestCookies.php
Go to the documentation of this file.
1<?php
2
3namespace Dflydev\FigCookies;
4
5use InvalidArgumentException;
7
9{
17 public static function get(RequestInterface $request, $name, $value = null)
18 {
20 if ($cookies->has($name)) {
21 return $cookies->get($name);
22 }
23
24 return Cookie::create($name, $value);
25 }
26
33 public static function set(RequestInterface $request, Cookie $cookie)
34 {
36 ->with($cookie)
37 ->renderIntoCookieHeader($request)
38 ;
39 }
40
48 public static function modify(RequestInterface $request, $name, $modify)
49 {
50 if (! is_callable($modify)) {
51 throw new InvalidArgumentException('$modify must be callable.');
52 }
53
55 $cookie = $modify($cookies->has($name)
56 ? $cookies->get($name)
58 );
59
60 return $cookies
61 ->with($cookie)
62 ->renderIntoCookieHeader($request)
63 ;
64 }
65
72 public static function remove(RequestInterface $request, $name)
73 {
75 ->without($name)
76 ->renderIntoCookieHeader($request)
77 ;
78 }
79}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
static create($name, $value=null)
Create a Cookie.
Definition: Cookie.php:73
static fromRequest(RequestInterface $request)
Create Cookies from a Request.
Definition: Cookies.php:121
static modify(RequestInterface $request, $name, $modify)
Representation of an outgoing, client-side request.