Code Duplication    Length = 14-17 lines in 2 locations

Filter/Widget/Search/FuzzySearch.php 1 location

@@ 33-49 (lines=17) @@
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function modifySearch(Search $search, FilterState $state = null, SearchRequest $request = null)
34
    {
35
        if ($state && $state->isActive()) {
36
            if (strpos($this->getField(), ',') !== false) {
37
                $subQuery = new BoolQuery();
38
                foreach (explode(',', $this->getField()) as $field) {
39
                    $subQuery->add(new FuzzyQuery($field, $state->getValue(), $this->getParameters()), 'should');
40
                }
41
                $search->addQuery($subQuery, 'must');
42
            } else {
43
                $search->addQuery(
44
                    new FuzzyQuery($this->getField(), $state->getValue(), $this->getParameters()),
45
                    'must'
46
                );
47
            }
48
        }
49
    }
50
51
    /**
52
     * @return array

Filter/Widget/Search/MatchSearch.php 1 location

@@ 28-41 (lines=14) @@
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function modifySearch(Search $search, FilterState $state = null, SearchRequest $request = null)
29
    {
30
        if ($state && $state->isActive()) {
31
            if (strpos($this->getField(), ',') !== false) {
32
                $subQuery = new BoolQuery();
33
                foreach (explode(',', $this->getField()) as $field) {
34
                    $subQuery->add(new MatchQuery($field, $state->getValue()), 'should');
35
                }
36
                $search->addQuery($subQuery, 'must');
37
            } else {
38
                $search->addQuery(new MatchQuery($this->getField(), $state->getValue()), 'must');
39
            }
40
        }
41
    }
42
}
43