Conditions | 3 |
Paths | 3 |
Total Lines | 118 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
206 | public function generateGlobalMap(bool $complete = true): array { |
||
207 | |||
208 | $params = [ |
||
209 | 'index' => $this->configService->getElasticIndex() |
||
210 | ]; |
||
211 | |||
212 | if ($complete === false) { |
||
213 | return $params; |
||
214 | } |
||
215 | |||
216 | if ($this->configService->getAppValue(ConfigService::ELASTIC_VER_BELOW66) !== '1') { |
||
217 | $params['include_type_name'] = true; |
||
218 | } |
||
219 | |||
220 | $params['body'] = [ |
||
221 | 'settings' => [ |
||
222 | 'index.mapping.total_fields.limit' => $this->configService->getAppValue( |
||
223 | ConfigService::FIELDS_LIMIT |
||
224 | ), |
||
225 | 'analysis' => [ |
||
226 | 'filter' => [ |
||
227 | 'shingle' => [ |
||
228 | 'type' => 'shingle' |
||
229 | ] |
||
230 | ], |
||
231 | 'char_filter' => [ |
||
232 | 'pre_negs' => [ |
||
233 | 'type' => 'pattern_replace', |
||
234 | 'pattern' => '(\\w+)\\s+((?i:never|no|nothing|nowhere|noone|none|not|havent|hasnt|hadnt|cant|couldnt|shouldnt|wont|wouldnt|dont|doesnt|didnt|isnt|arent|aint))\\b', |
||
235 | 'replacement' => '~$1 $2' |
||
236 | ], |
||
237 | 'post_negs' => [ |
||
238 | 'type' => 'pattern_replace', |
||
239 | 'pattern' => '\\b((?i:never|no|nothing|nowhere|noone|none|not|havent|hasnt|hadnt|cant|couldnt|shouldnt|wont|wouldnt|dont|doesnt|didnt|isnt|arent|aint))\\s+(\\w+)', |
||
240 | 'replacement' => '$1 ~$2' |
||
241 | ] |
||
242 | ], |
||
243 | 'analyzer' => [ |
||
244 | 'analyzer' => [ |
||
245 | 'type' => 'custom', |
||
246 | 'tokenizer' => $this->configService->getAppValue( |
||
247 | ConfigService::ANALYZER_TOKENIZER |
||
248 | ), |
||
249 | 'filter' => ['lowercase', 'stop', 'kstem'] |
||
250 | ] |
||
251 | ] |
||
252 | ] |
||
253 | ], |
||
254 | 'mappings' => [ |
||
255 | 'standard' => [ |
||
256 | 'dynamic' => true, |
||
257 | 'properties' => [ |
||
258 | 'source' => [ |
||
259 | 'type' => 'keyword' |
||
260 | ], |
||
261 | 'title' => [ |
||
262 | 'type' => 'text', |
||
263 | 'analyzer' => 'keyword', |
||
264 | 'term_vector' => 'with_positions_offsets', |
||
265 | 'copy_to' => 'combined' |
||
266 | ], |
||
267 | 'provider' => [ |
||
268 | 'type' => 'keyword' |
||
269 | ], |
||
270 | 'tags' => [ |
||
271 | 'type' => 'keyword' |
||
272 | ], |
||
273 | 'metatags' => [ |
||
274 | 'type' => 'keyword' |
||
275 | ], |
||
276 | 'subtags' => [ |
||
277 | 'type' => 'keyword' |
||
278 | ], |
||
279 | 'content' => [ |
||
280 | 'type' => 'text', |
||
281 | 'analyzer' => 'analyzer', |
||
282 | 'term_vector' => 'with_positions_offsets', |
||
283 | 'copy_to' => 'combined' |
||
284 | ], |
||
285 | 'owner' => [ |
||
286 | 'type' => 'keyword' |
||
287 | ], |
||
288 | 'users' => [ |
||
289 | 'type' => 'keyword' |
||
290 | ], |
||
291 | 'groups' => [ |
||
292 | 'type' => 'keyword' |
||
293 | ], |
||
294 | 'circles' => [ |
||
295 | 'type' => 'keyword' |
||
296 | ], |
||
297 | 'links' => [ |
||
298 | 'type' => 'keyword' |
||
299 | ], |
||
300 | 'hash' => [ |
||
301 | 'type' => 'keyword' |
||
302 | ], |
||
303 | 'combined' => [ |
||
304 | 'type' => 'text', |
||
305 | 'analyzer' => 'analyzer', |
||
306 | 'term_vector' => 'with_positions_offsets' |
||
307 | ] |
||
308 | // , |
||
309 | // 'topics' => [ |
||
310 | // 'type' => 'text', |
||
311 | // 'index' => 'not_analyzed' |
||
312 | // ], |
||
313 | // 'places' => [ |
||
314 | // 'type' => 'text', |
||
315 | // 'index' => 'not_analyzed' |
||
316 | // ] |
||
317 | ] |
||
318 | ] |
||
319 | ] |
||
320 | ]; |
||
321 | |||
322 | return $params; |
||
323 | } |
||
324 | |||
383 |