1 | <?php |
||
23 | class Negotiation |
||
24 | { |
||
25 | /** |
||
26 | * @var FieldTokenizer |
||
27 | */ |
||
28 | private $tokenizer; |
||
29 | |||
30 | /** |
||
31 | * @var FieldParser |
||
32 | */ |
||
33 | private $parser; |
||
34 | |||
35 | /** |
||
36 | * @var Negotiator |
||
37 | */ |
||
38 | private $negotiator; |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Constructor, initialise factories. |
||
43 | */ |
||
44 | 76 | public function __construct() |
|
53 | |||
54 | /** |
||
55 | * Parse the Accept-Charset field & negotiate against server preferences, returns the preferred variant. |
||
56 | * |
||
57 | * @param string $clientField |
||
58 | * @param string $serverField |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | 8 | public function charsetBest($clientField, $serverField) |
|
66 | |||
67 | /** |
||
68 | * Parse the Accept-Charset field & negotiate against server preferences, returns a sorted array of preferences. |
||
69 | * |
||
70 | * @param string $clientField |
||
71 | * @param string $serverField |
||
72 | * |
||
73 | * @throws \LogicException |
||
74 | * |
||
75 | * @return MatchedPreferenceInterface[] |
||
76 | */ |
||
77 | 7 | public function charsetAll($clientField, $serverField) |
|
81 | |||
82 | /** |
||
83 | * Parse the Accept-Encoding field & negotiate against server preferences, returns the preferred variant. |
||
84 | * |
||
85 | * @param string $clientField |
||
86 | * @param string $serverField |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | 7 | public function encodingBest($clientField, $serverField) |
|
94 | |||
95 | /** |
||
96 | * Parse the Accept-Encoding field & negotiate against server preferences, returns a sorted array of preferences. |
||
97 | * |
||
98 | * @param string $clientField |
||
99 | * @param string $serverField |
||
100 | * |
||
101 | * @throws \LogicException |
||
102 | * |
||
103 | * @return MatchedPreferenceInterface[] |
||
104 | */ |
||
105 | 7 | public function encodingAll($clientField, $serverField) |
|
109 | |||
110 | /** |
||
111 | * Parse the Accept-Language field & negotiate against server preferences, returns the preferred variant. |
||
112 | * |
||
113 | * @param string $clientField |
||
114 | * @param string $serverField |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | 10 | public function languageBest($clientField, $serverField) |
|
122 | |||
123 | /** |
||
124 | * Parse the Accept-Language field & negotiate against server preferences, returns a sorted array of preferences. |
||
125 | * |
||
126 | * @param string $clientField |
||
127 | * @param string $serverField |
||
128 | * |
||
129 | * @throws \LogicException |
||
130 | * |
||
131 | * @return MatchedPreferenceInterface[] |
||
132 | */ |
||
133 | 10 | public function languageAll($clientField, $serverField) |
|
137 | |||
138 | /** |
||
139 | * Parse the Accept field & negotiate against server preferences, returns the preferred variant. |
||
140 | * |
||
141 | * @param string $clientField |
||
142 | * @param string $serverField |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | 12 | public function mimeBest($clientField, $serverField) |
|
150 | |||
151 | /** |
||
152 | * Parse the Accept field & negotiate against server preferences, returns a sorted array of preferences. |
||
153 | * |
||
154 | * @param string $clientField |
||
155 | * @param string $serverField |
||
156 | * |
||
157 | * @throws \LogicException |
||
158 | * |
||
159 | * @return MatchedPreferenceInterface[] |
||
160 | */ |
||
161 | 16 | public function mimeAll($clientField, $serverField) |
|
165 | |||
166 | /** |
||
167 | * Shared code to parse an Accept* field & negotiate against server preferences, returns the preferred variant. |
||
168 | * |
||
169 | * @param string $clientField |
||
170 | * @param string $serverField |
||
171 | * @param string $fromField |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | 36 | private function genericBest($clientField, $serverField, $fromField) |
|
182 | |||
183 | /** |
||
184 | * Shared code to parse an Accept* field & negotiate against server preferences, returns an array of preferences. |
||
185 | * |
||
186 | * @param string $clientField |
||
187 | * @param string $serverField |
||
188 | * @param string $fromField |
||
189 | * |
||
190 | * @return MatchedPreferenceInterface[] |
||
191 | */ |
||
192 | 40 | private function genericAll($clientField, $serverField, $fromField) |
|
199 | |||
200 | /** |
||
201 | * Parse client preferences and return an array of Preference instances |
||
202 | * |
||
203 | * @param bool $serverField |
||
204 | * @param string $field |
||
205 | * @param string $fromField |
||
206 | * |
||
207 | * @return PreferenceInterface[] |
||
208 | */ |
||
209 | 76 | private function parsePreferences($serverField, $field, $fromField) |
|
215 | } |
||
216 |