Total Complexity | 6 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
12 | class CookieMiddleware implements MiddlewareInterface |
||
13 | { |
||
14 | private $cookieJar; |
||
15 | |||
16 | public function __construct() |
||
17 | { |
||
18 | $this->cookieJar = new CookieJar(); |
||
19 | } |
||
20 | |||
21 | public function setCookies(array $cookies): void |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @return Cookie[] |
||
28 | */ |
||
29 | public function getCookies(): array |
||
30 | { |
||
31 | return $this->cookieJar->getCookies(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Adds a cookie to the current cookie jar. |
||
36 | * |
||
37 | * @param Cookie $cookie A cookie object |
||
38 | */ |
||
39 | public function addCookie(Cookie $cookie): void |
||
42 | } |
||
43 | |||
44 | public function handleRequest(RequestInterface $request, callable $next) |
||
45 | { |
||
46 | $this->cookieJar->clearExpiredCookies(); |
||
47 | $request = $this->cookieJar->addCookieHeaders($request); |
||
48 | |||
49 | return $next($request); |
||
50 | } |
||
51 | |||
52 | public function handleResponse(RequestInterface $request, ResponseInterface $response, callable $next) |
||
57 | } |
||
58 | } |
||
59 |