ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
CookieJarWrapper.php
Go to the documentation of this file.
1<?php
2
3namespace ILIAS\HTTP\Cookies;
4
7
19{
20
24 private $cookies;
25
26
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}
An exception for terminatinating execution or to throw for unit testing.
renderIntoResponseHeader(ResponseInterface $response)
@inheritDoc
__construct(SetCookies $cookies)
CookieJarWrapper constructor.
with(Cookie $setCookie)
Creates a new cookie jar with the given cookie.
Representation of an outgoing, server-side response.
if($format !==null) $name
Definition: metadata.php:146
Class CookieJarWrapperTest.
Definition: Cookie.php:3
$response