1: <?php
2: /*
3: * Copyright (c) 2015 @trashtoy
4: * https://github.com/trashtoy/
5: *
6: * Permission is hereby granted, free of charge, to any person obtaining a copy of
7: * this software and associated documentation files (the "Software"), to deal in
8: * the Software without restriction, including without limitation the rights to use,
9: * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
10: * Software, and to permit persons to whom the Software is furnished to do so,
11: * subject to the following conditions:
12: *
13: * The above copyright notice and this permission notice shall be included in all
14: * copies or substantial portions of the Software.
15: *
16: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18: * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19: * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20: * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21: * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22: */
23: /**
24: * PHP class file.
25: * @auhtor trashtoy
26: * @since 2.2.0
27: */
28: namespace Peach\Http\Header;
29:
30: use Peach\Http\SingleHeaderField;
31: use Peach\Http\Util;
32:
33: /**
34: * 単純なテキストデータをあらわす HeaderField です.
35: *
36: * このクラスの format() および getValue() は同じ結果を返します.
37: */
38: class Raw implements SingleHeaderField
39: {
40: /**
41: * ヘッダー名をあらわす文字列です.
42: *
43: * @var string
44: */
45: private $name;
46:
47: /**
48: * ヘッダー値をあらわす文字列です.
49: *
50: * @var string
51: */
52: private $value;
53:
54: /**
55: * 指定されたヘッダー名およびヘッダー値を持つ Raw オブジェクトを構築します.
56: *
57: * @param string $name ヘッダー名
58: * @param string $value ヘッダー値
59: */
60: public function __construct($name, $value)
61: {
62: Util::validateHeaderName($name);
63: $this->name = $name;
64: $this->value = $value;
65: }
66:
67: /**
68: * このヘッダーの値をそのまま返します.
69: *
70: * @return string ヘッダー値
71: */
72: public function format()
73: {
74: return $this->value;
75: }
76:
77: /**
78: * この HeaderField のヘッダー名を返します.
79: *
80: * @return string ヘッダー名
81: */
82: public function getName()
83: {
84: return $this->name;
85: }
86:
87: /**
88: * この HeaderField のヘッダー値として使用される値を返します.
89: *
90: * @return string ヘッダー値として使用される値
91: */
92: public function getValue()
93: {
94: return $this->value;
95: }
96: }
97: