1 | <?php |
||
19 | class AcceptHeaderItem |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $value; |
||
25 | |||
26 | /** |
||
27 | * @var float |
||
28 | */ |
||
29 | private $priority = 1.0; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $parameters = array(); |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | private $index = null; |
||
40 | |||
41 | /** |
||
42 | * Constructor. |
||
43 | * |
||
44 | * @param string $value |
||
45 | * @param array|null $parameters |
||
46 | */ |
||
47 | public function __construct($value, array $parameters = null) |
||
57 | |||
58 | /** |
||
59 | * Set a parameter. |
||
60 | * |
||
61 | * @param string $name |
||
62 | * @param string $value |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function setParameter($name, $value) |
||
76 | |||
77 | /** |
||
78 | * Factory create AcceptHeaderItem from string. |
||
79 | * |
||
80 | * @param string $itemString |
||
81 | * |
||
82 | * @return $this |
||
83 | */ |
||
84 | public static function fromString($itemString) |
||
108 | |||
109 | /** |
||
110 | * Return header item value. |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getValue() |
||
118 | |||
119 | /** |
||
120 | * Get accept header item quality. |
||
121 | * |
||
122 | * @return float |
||
123 | */ |
||
124 | public function getPriority() |
||
128 | |||
129 | /** |
||
130 | * Set accept header item quality. |
||
131 | * |
||
132 | * @param float|int $priority |
||
133 | * |
||
134 | * @return $this |
||
135 | * |
||
136 | * @throws InvalidArgumentException |
||
137 | */ |
||
138 | public function setPriority($priority) |
||
150 | |||
151 | /** |
||
152 | * Get all parameters. |
||
153 | * |
||
154 | * @return array |
||
155 | */ |
||
156 | public function getParameters() |
||
160 | |||
161 | /** |
||
162 | * Return parameter by name or default value if not exist. |
||
163 | * |
||
164 | * @param string $name |
||
165 | * @param string|null $default |
||
166 | * |
||
167 | * @return string|null |
||
168 | */ |
||
169 | public function getParameter($name, $default = null) |
||
177 | |||
178 | /** |
||
179 | * Check if parameter exist by name. |
||
180 | * |
||
181 | * @param string $name |
||
182 | * |
||
183 | * @return bool |
||
184 | */ |
||
185 | public function hasParameter($name) |
||
189 | |||
190 | /** |
||
191 | * Set accept header item index. |
||
192 | * |
||
193 | * @param int $index |
||
194 | * |
||
195 | * @return $this |
||
196 | */ |
||
197 | public function setIndex($index) |
||
203 | |||
204 | /** |
||
205 | * Get index. |
||
206 | * |
||
207 | * @return int |
||
208 | */ |
||
209 | public function getIndex() |
||
213 | |||
214 | /** |
||
215 | * Cast accept item to string representation. |
||
216 | * |
||
217 | * @return string |
||
218 | */ |
||
219 | public function __toString() |
||
232 | |||
233 | } |
||
234 |