ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CookieJarWrapper.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\HTTP\Cookies;
20
21use Dflydev\FigCookies\SetCookies;
22use Psr\Http\Message\ResponseInterface;
23
35{
39 public function __construct(private SetCookies $cookies)
40 {
41 }
42
43
47 public function has(string $name): bool
48 {
49 return $this->cookies->has($name);
50 }
51
52
56 public function get(string $name): ?Cookie
57 {
58 $cookie = $this->cookies->get($name);
59
60 return (is_null($cookie)) ? null : new CookieWrapper($cookie);
61 }
62
63
67 public function getAll(): array
68 {
69 $wrappedCookies = [];
70 foreach ($this->cookies->getAll() as $cookie) {
71 $wrappedCookies[] = new CookieWrapper($cookie);
72 }
73
74 return $wrappedCookies;
75 }
76
77
81 public function with(Cookie $setCookie): CookieJar
82 {
86 $wrapper = $setCookie;
87 $internalCookie = $wrapper->getImplementation();
88
89 $clone = clone $this;
90 $clone->cookies = $this->cookies->with($internalCookie);
91
92 return $clone;
93 }
94
95
99 public function without(string $name): CookieJar
100 {
101 $clone = clone $this;
102 $clone->cookies = $this->cookies->without($name);
103
104 return $clone;
105 }
106
107
111 public function renderIntoResponseHeader(ResponseInterface $response): ResponseInterface
112 {
113 return $this->cookies->renderIntoSetCookieHeader($response);
114 }
115}
renderIntoResponseHeader(ResponseInterface $response)
@inheritDoc
__construct(private SetCookies $cookies)
CookieJarWrapper constructor.
without(string $name)
@inheritDoc
with(Cookie $setCookie)
Creates a new cookie jar with the given cookie.
without(string $name)
Creates a cookie jar without the specified cookie.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Cookie.php:19
$response
Definition: xapitoken.php:93