1: <?php
2:
3: namespace PHPixie\HTTP\Data\Headers;
4:
5: 6: 7:
8: class Editable extends \PHPixie\HTTP\Data\Headers
9: {
10: 11: 12: 13: 14:
15: public function set($name, $value)
16: {
17: $value = $this->normalizeValue($value);
18:
19: $this->remove($name);
20: $this->setHeader($name, $value);
21: }
22:
23: 24: 25: 26: 27:
28: public function add($name, $value)
29: {
30: $this->requireNames();
31: $value = $this->normalizeValue($value);
32:
33: $lower = strtolower($name);
34: if(array_key_exists($lower, $this->names)) {
35: $name = $this->names[$lower];
36: foreach($value as $line) {
37: $this->headers[$name][] = $line;
38: }
39: }else{
40: $this->setHeader($name, $value);
41: }
42: }
43:
44: 45: 46: 47:
48: public function remove($name)
49: {
50: $this->requireNames();
51:
52: $lower = strtolower($name);
53: if(array_key_exists($lower, $this->names)) {
54: $name = $this->names[$lower];
55: unset($this->names[$lower]);
56: unset($this->headers[$name]);
57: }
58: }
59:
60: 61: 62: 63:
64: protected function setHeader($name, $value)
65: {
66: $this->headers[$name] = $value;
67: $this->names[strtolower($name)] = $name;
68: }
69: }