1 | <?php declare(strict_types=1); |
||
12 | final class HttpHeaderBag implements Iterator |
||
13 | { |
||
14 | /** @var HttpHeader[] */ |
||
15 | private $headers = []; |
||
16 | |||
17 | 2 | public function add(HttpHeader $headerValue) |
|
18 | { |
||
19 | 2 | $this->headers[] = $headerValue; |
|
20 | 2 | } |
|
21 | |||
22 | 2 | public function has(string $headerName): bool |
|
23 | { |
||
24 | 2 | foreach ($this->headers as $header) { |
|
25 | 2 | if ($header->name() === $headerName) { |
|
26 | 1 | return true; |
|
27 | } |
||
28 | } |
||
29 | |||
30 | 2 | return false; |
|
31 | } |
||
32 | |||
33 | public function get(string $headerName): array |
||
45 | |||
46 | public function getFirst(string $headerName): HttpHeader |
||
50 | |||
51 | /** @return HttpHeader|bool */ |
||
52 | 2 | public function current() |
|
53 | { |
||
54 | 2 | return current($this->headers); |
|
55 | } |
||
56 | |||
57 | 2 | public function next() |
|
58 | { |
||
59 | 2 | return next($this->headers); |
|
60 | } |
||
61 | |||
62 | public function key() |
||
66 | |||
67 | 2 | public function valid() |
|
68 | { |
||
69 | 2 | return $this->current() !== false; |
|
70 | } |
||
71 | |||
72 | 2 | public function rewind() |
|
76 | } |
||
77 |