These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\SearchBundle\Search; |
||
4 | |||
5 | View Code Duplication | class NGramAnalysisFactory extends AbstractAnalysisFactory |
|
0 ignored issues
–
show
|
|||
6 | { |
||
7 | /** |
||
8 | * @param string $language |
||
9 | * |
||
10 | * @return AnalysisFactoryInterface |
||
11 | */ |
||
12 | public function addIndexAnalyzer($language) |
||
13 | { |
||
14 | $this->analyzers['default'] = array( |
||
15 | 'type' => 'custom', |
||
16 | 'tokenizer' => 'kuma_ngram', |
||
17 | 'filter' => array( |
||
18 | 'trim', |
||
19 | 'lowercase', |
||
20 | $language . '_stop', |
||
21 | $language . '_stemmer', |
||
22 | 'asciifolding', |
||
23 | 'strip_special_chars', |
||
24 | ), |
||
25 | ); |
||
26 | |||
27 | return $this; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param string $language |
||
32 | * |
||
33 | * @return AnalysisFactoryInterface |
||
34 | */ |
||
35 | public function addSuggestionAnalyzer($language) |
||
36 | { |
||
37 | $this->analyzers['default_search'] = array( |
||
38 | 'type' => 'custom', |
||
39 | 'tokenizer' => 'kuma_ngram', |
||
40 | 'filter' => array( |
||
41 | 'trim', |
||
42 | 'lowercase', |
||
43 | $language . '_stop', |
||
44 | $language . '_stemmer', |
||
45 | 'asciifolding', |
||
46 | 'strip_special_chars', |
||
47 | ), |
||
48 | ); |
||
49 | |||
50 | return $this; |
||
51 | } |
||
52 | } |
||
53 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.