Code Duplication    Length = 18-31 lines in 2 locations

DSL/SearchEndpoint/FilterEndpoint.php 1 location

@@ 21-51 (lines=31) @@
18
/**
19
 * Search filter dsl endpoint.
20
 */
21
class FilterEndpoint extends QueryEndpoint
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
27
    {
28
        if ($this->getBuilder()) {
29
            $query = new FilteredQuery();
30
            !$this->isBool() ? : $this->getBuilder()->setParameters($this->getParameters());
31
            $query->setFilter($this->getBuilder());
32
            $this->addReference('filtered_query', $query);
33
        }
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getOrder()
40
    {
41
        return 1;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function getBoolInstance()
48
    {
49
        return new BoolFilter();
50
    }
51
}
52

DSL/SearchEndpoint/PostFilterEndpoint.php 1 location

@@ 20-37 (lines=18) @@
17
/**
18
 * Search post filter dsl endpoint.
19
 */
20
class PostFilterEndpoint extends FilterEndpoint
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
26
    {
27
        if ($this->getBuilder()) {
28
            $postFilter = new PostFilter();
29
            !$this->isBool() ? : $this->getBuilder()->setParameters($this->getParameters());
30
            $postFilter->setFilter($this->getBuilder());
31
32
            return $postFilter->toArray();
33
        }
34
35
        return null;
36
    }
37
}
38