ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CookieJarWrapper.php
Go to the documentation of this file.
1 <?php
2 
3 namespace ILIAS\HTTP\Cookies;
4 
7 
18 class CookieJarWrapper implements CookieJar
19 {
20 
24  private $cookies;
25 
26 
32  public function __construct(SetCookies $cookies)
33  {
34  $this->cookies = $cookies;
35  }
36 
37 
41  public function has($name)
42  {
43  return $this->cookies->has($name);
44  }
45 
46 
50  public function get($name)
51  {
52  $cookie = $this->cookies->get($name);
53 
54  return (is_null($cookie)) ? null : new CookieWrapper($cookie);
55  }
56 
57 
61  public function getAll()
62  {
63  $wrappedCookies = [];
64  foreach ($this->cookies->getAll() as $cookie) {
65  $wrappedCookies[] = new CookieWrapper($cookie);
66  }
67 
68  return $wrappedCookies;
69  }
70 
71 
75  public function with(Cookie $setCookie)
76  {
80  $wrapper = $setCookie;
81  $internalCookie = $wrapper->getImplementation();
82 
83  $clone = clone $this;
84  $clone->cookies = $this->cookies->with($internalCookie);
85 
86  return $clone;
87  }
88 
89 
93  public function without($name)
94  {
95  $clone = clone $this;
96  $clone->cookies = $this->cookies->without($name);
97 
98  return $clone;
99  }
100 
101 
106  {
107  $response = $this->cookies->renderIntoSetCookieHeader($response);
108 
109  return $response;
110  }
111 }
Class CookieJarWrapperTest.
Definition: Cookie.php:3
renderIntoResponseHeader(ResponseInterface $response)
Representation of an outgoing, server-side response.
with(Cookie $setCookie)
Creates a new cookie jar with the given cookie.
__construct(SetCookies $cookies)
CookieJarWrapper constructor.
$response