ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
FigResponseCookies.php
Go to the documentation of this file.
1<?php
2
3namespace Dflydev\FigCookies;
4
5use InvalidArgumentException;
7
9{
17 public static function get(ResponseInterface $response, $name, $value = null)
18 {
20 if ($setCookies->has($name)) {
21 return $setCookies->get($name);
22 }
23
24 return SetCookie::create($name, $value);
25 }
26
33 public static function set(ResponseInterface $response, SetCookie $setCookie)
34 {
36 ->with($setCookie)
37 ->renderIntoSetCookieHeader($response)
38 ;
39 }
40
48 {
50 }
51
59 public static function modify(ResponseInterface $response, $name, $modify)
60 {
61 if (! is_callable($modify)) {
62 throw new InvalidArgumentException('$modify must be callable.');
63 }
64
66 $setCookie = $modify($setCookies->has($name)
67 ? $setCookies->get($name)
69 );
70
71 return $setCookies
72 ->with($setCookie)
73 ->renderIntoSetCookieHeader($response)
74 ;
75 }
76
83 public static function remove(ResponseInterface $response, $name)
84 {
86 ->without($name)
87 ->renderIntoSetCookieHeader($response)
88 ;
89 }
90}
An exception for terminatinating execution or to throw for unit testing.
static expire(ResponseInterface $response, $cookieName)
static modify(ResponseInterface $response, $name, $modify)
static create($name, $value=null)
Definition: SetCookie.php:173
static fromResponse(ResponseInterface $response)
Create SetCookies from a Response.
Definition: SetCookies.php:124
Representation of an outgoing, server-side response.
if($format !==null) $name
Definition: metadata.php:146
$response
$cookieName