Total Complexity | 7 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class ResponseHeader |
||
18 | { |
||
19 | protected $headers = array(); |
||
20 | |||
21 | /** |
||
22 | * Add a header |
||
23 | * |
||
24 | * @param string $key |
||
25 | * @param string|null $value (optional) |
||
26 | */ |
||
27 | public function set($key, $value = null) |
||
28 | { |
||
29 | if ($value === null && strpos($key, ':')) |
||
30 | { |
||
31 | $split = array_map('trim', explode(':', $key)); |
||
32 | $key = $split[0]; |
||
33 | $value = $split[1]; |
||
34 | } |
||
35 | |||
36 | $this->headers[$key] = $value; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Send the headers |
||
41 | * |
||
42 | * @return string[] |
||
43 | */ |
||
44 | public function get() |
||
45 | { |
||
46 | $return = array(); |
||
47 | |||
48 | foreach ($this->headers as $key => $value) |
||
49 | { |
||
50 | $return[] = $key . ': ' . $value; |
||
51 | } |
||
52 | |||
53 | return $return; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Add a header |
||
58 | * |
||
59 | * @param string $key |
||
60 | */ |
||
61 | public function remove($key) |
||
66 | } |
||
67 | } |
||
68 | } |
||
69 |