Conditions | 1 |
Paths | 1 |
Total Lines | 241 |
Code Lines | 160 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
52 | public function hostParsingDataProvider(): array |
||
53 | { |
||
54 | return [ |
||
55 | 'host' => [ |
||
56 | [ |
||
57 | 'HTTP_HOST' => 'test', |
||
58 | 'REQUEST_METHOD' => 'GET', |
||
59 | ], |
||
60 | [ |
||
61 | 'method' => 'GET', |
||
62 | 'host' => 'test', |
||
63 | 'port' => null, |
||
64 | 'protocol' => '1.1', |
||
65 | 'scheme' => 'http', |
||
66 | 'path' => '', |
||
67 | 'query' => '', |
||
68 | ] |
||
69 | ], |
||
70 | 'hostWithPort' => [ |
||
71 | [ |
||
72 | 'HTTP_HOST' => 'test:88', |
||
73 | 'REQUEST_METHOD' => 'GET', |
||
74 | ], |
||
75 | [ |
||
76 | 'method' => 'GET', |
||
77 | 'host' => 'test', |
||
78 | 'port' => 88, |
||
79 | 'protocol' => '1.1', |
||
80 | 'scheme' => 'http', |
||
81 | 'path' => '', |
||
82 | 'query' => '', |
||
83 | |||
84 | ] |
||
85 | ], |
||
86 | 'ipv4' => [ |
||
87 | [ |
||
88 | 'HTTP_HOST' => '127.0.0.1', |
||
89 | 'REQUEST_METHOD' => 'GET', |
||
90 | 'HTTPS' => true |
||
91 | ], |
||
92 | [ |
||
93 | 'method' => 'GET', |
||
94 | 'host' => '127.0.0.1', |
||
95 | 'port' => null, |
||
96 | 'protocol' => '1.1', |
||
97 | 'scheme' => 'https', |
||
98 | 'path' => '', |
||
99 | 'query' => '', |
||
100 | ] |
||
101 | ], |
||
102 | 'ipv4WithPort' => [ |
||
103 | [ |
||
104 | 'HTTP_HOST' => '127.0.0.1:443', |
||
105 | 'REQUEST_METHOD' => 'GET' |
||
106 | ], |
||
107 | [ |
||
108 | 'method' => 'GET', |
||
109 | 'host' => '127.0.0.1', |
||
110 | 'port' => 443, |
||
111 | 'protocol' => '1.1', |
||
112 | 'scheme' => 'http', |
||
113 | 'path' => '', |
||
114 | 'query' => '', |
||
115 | ] |
||
116 | ], |
||
117 | 'ipv6' => [ |
||
118 | [ |
||
119 | 'HTTP_HOST' => '[::1]', |
||
120 | 'REQUEST_METHOD' => 'GET' |
||
121 | ], |
||
122 | [ |
||
123 | 'method' => 'GET', |
||
124 | 'host' => '[::1]', |
||
125 | 'port' => null, |
||
126 | 'protocol' => '1.1', |
||
127 | 'scheme' => 'http', |
||
128 | 'path' => '', |
||
129 | 'query' => '', |
||
130 | ] |
||
131 | ], |
||
132 | 'ipv6WithPort' => [ |
||
133 | [ |
||
134 | 'HTTP_HOST' => '[::1]:443', |
||
135 | 'REQUEST_METHOD' => 'GET' |
||
136 | ], |
||
137 | [ |
||
138 | 'method' => 'GET', |
||
139 | 'host' => '[::1]', |
||
140 | 'port' => 443, |
||
141 | 'protocol' => '1.1', |
||
142 | 'scheme' => 'http', |
||
143 | 'path' => '', |
||
144 | 'query' => '', |
||
145 | ] |
||
146 | ], |
||
147 | 'serverName' => [ |
||
148 | [ |
||
149 | 'SERVER_NAME' => 'test', |
||
150 | 'REQUEST_METHOD' => 'GET' |
||
151 | ], |
||
152 | [ |
||
153 | 'method' => 'GET', |
||
154 | 'host' => 'test', |
||
155 | 'port' => null, |
||
156 | 'protocol' => '1.1', |
||
157 | 'scheme' => 'http', |
||
158 | 'path' => '', |
||
159 | 'query' => '', |
||
160 | ] |
||
161 | ], |
||
162 | 'hostAndServerName' => [ |
||
163 | [ |
||
164 | 'SERVER_NAME' => 'override', |
||
165 | 'HTTP_HOST' => 'test', |
||
166 | 'REQUEST_METHOD' => 'GET', |
||
167 | 'SERVER_PORT' => 81 |
||
168 | ], |
||
169 | [ |
||
170 | 'method' => 'GET', |
||
171 | 'host' => 'test', |
||
172 | 'port' => 81, |
||
173 | 'protocol' => '1.1', |
||
174 | 'scheme' => 'http', |
||
175 | 'path' => '', |
||
176 | 'query' => '', |
||
177 | ] |
||
178 | ], |
||
179 | 'none' => [ |
||
180 | [ |
||
181 | 'REQUEST_METHOD' => 'GET' |
||
182 | ], |
||
183 | [ |
||
184 | 'method' => 'GET', |
||
185 | 'host' => '', |
||
186 | 'port' => null, |
||
187 | 'protocol' => '1.1', |
||
188 | 'scheme' => 'http', |
||
189 | 'path' => '', |
||
190 | 'query' => '', |
||
191 | ] |
||
192 | ], |
||
193 | 'path' => [ |
||
194 | [ |
||
195 | 'REQUEST_METHOD' => 'GET', |
||
196 | 'REQUEST_URI' => '/path/to/folder?param=1' |
||
197 | ], |
||
198 | [ |
||
199 | 'method' => 'GET', |
||
200 | 'host' => '', |
||
201 | 'port' => null, |
||
202 | 'protocol' => '1.1', |
||
203 | 'scheme' => 'http', |
||
204 | 'path' => '/path/to/folder', |
||
205 | 'query' => '', |
||
206 | ] |
||
207 | ], |
||
208 | 'query' => [ |
||
209 | [ |
||
210 | 'REQUEST_METHOD' => 'GET', |
||
211 | 'QUERY_STRING' => 'path/to/folder?param=1' |
||
212 | ], |
||
213 | [ |
||
214 | 'method' => 'GET', |
||
215 | 'host' => '', |
||
216 | 'port' => null, |
||
217 | 'protocol' => '1.1', |
||
218 | 'scheme' => 'http', |
||
219 | 'path' => '', |
||
220 | 'query' => 'path/to/folder?param=1', |
||
221 | ] |
||
222 | ], |
||
223 | 'protocol' => [ |
||
224 | [ |
||
225 | 'REQUEST_METHOD' => 'GET', |
||
226 | 'SERVER_PROTOCOL' => 'HTTP/1.0' |
||
227 | ], |
||
228 | [ |
||
229 | 'method' => 'GET', |
||
230 | 'host' => '', |
||
231 | 'port' => null, |
||
232 | 'protocol' => '1.0', |
||
233 | 'scheme' => 'http', |
||
234 | 'path' => '', |
||
235 | 'query' => '', |
||
236 | ] |
||
237 | ], |
||
238 | 'post' => [ |
||
239 | [ |
||
240 | 'REQUEST_METHOD' => 'POST', |
||
241 | ], |
||
242 | [ |
||
243 | 'method' => 'POST', |
||
244 | 'host' => '', |
||
245 | 'port' => null, |
||
246 | 'protocol' => '1.1', |
||
247 | 'scheme' => 'http', |
||
248 | 'path' => '', |
||
249 | 'query' => '', |
||
250 | ] |
||
251 | ], |
||
252 | 'delete' => [ |
||
253 | [ |
||
254 | 'REQUEST_METHOD' => 'DELETE', |
||
255 | ], |
||
256 | [ |
||
257 | 'method' => 'DELETE', |
||
258 | 'host' => '', |
||
259 | 'port' => null, |
||
260 | 'protocol' => '1.1', |
||
261 | 'scheme' => 'http', |
||
262 | 'path' => '', |
||
263 | 'query' => '', |
||
264 | ] |
||
265 | ], |
||
266 | 'put' => [ |
||
267 | [ |
||
268 | 'REQUEST_METHOD' => 'PUT', |
||
269 | ], |
||
270 | [ |
||
271 | 'method' => 'PUT', |
||
272 | 'host' => '', |
||
273 | 'port' => null, |
||
274 | 'protocol' => '1.1', |
||
275 | 'scheme' => 'http', |
||
276 | 'path' => '', |
||
277 | 'query' => '', |
||
278 | ] |
||
279 | ], |
||
280 | 'https' => [ |
||
281 | [ |
||
282 | 'REQUEST_METHOD' => 'PUT', |
||
283 | 'HTTPS' => 'on' |
||
284 | ], |
||
285 | [ |
||
286 | 'method' => 'PUT', |
||
287 | 'host' => '', |
||
288 | 'port' => null, |
||
289 | 'protocol' => '1.1', |
||
290 | 'scheme' => 'https', |
||
291 | 'path' => '', |
||
292 | 'query' => '', |
||
293 | ] |
||
304 |