Total Complexity | 11 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Coverage | 12% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
12 | final class ParsedHeaderBag implements Iterator |
||
13 | { |
||
14 | /** @var AbstractParsedHeader[] */ |
||
15 | private $headers = []; |
||
16 | |||
17 | 2 | public function add(AbstractParsedHeader $header): void |
|
18 | { |
||
19 | 2 | $this->headers[] = $header; |
|
20 | 2 | } |
|
21 | |||
22 | /** @return AbstractParsedHeader[] */ |
||
23 | public function findMultiple(string $name): array |
||
24 | { |
||
25 | $headers = []; |
||
26 | |||
27 | foreach ($this->headers as $header) { |
||
28 | if ($header->name() === $name) { |
||
29 | $headers[] = $header; |
||
30 | } |
||
31 | } |
||
32 | |||
33 | return $headers; |
||
34 | } |
||
35 | |||
36 | public function findOne(string $name): ?AbstractParsedHeader |
||
37 | { |
||
38 | $headers = $this->findMultiple($name); |
||
39 | |||
40 | if (count($headers) === 1) { |
||
41 | return $headers[0]; |
||
42 | } |
||
43 | |||
44 | return null; |
||
45 | } |
||
46 | |||
47 | /** @return AbstractParsedHeader */ |
||
48 | public function current() |
||
49 | { |
||
50 | return current($this->headers); |
||
51 | } |
||
52 | |||
53 | public function next() |
||
56 | } |
||
57 | |||
58 | public function key() |
||
61 | } |
||
62 | |||
63 | public function valid() |
||
66 | } |
||
67 | |||
68 | public function rewind() |
||
73 |