Code Duplication    Length = 38-43 lines in 6 locations

src/Query/IdsQuery.php 1 location

@@ 22-62 (lines=41) @@
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html
21
 */
22
class IdsQuery implements BuilderInterface
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var array
28
     */
29
    private $values;
30
31
    /**
32
     * @param array $values
33
     * @param array $parameters
34
     */
35
    public function __construct(array $values, array $parameters = [])
36
    {
37
        $this->values = $values;
38
        $this->setParameters($parameters);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getType()
45
    {
46
        return 'ids';
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function toArray()
53
    {
54
        $query = [
55
            'values' => $this->values,
56
        ];
57
58
        $output = $this->processArray($query);
59
60
        return [$this->getType() => $output];
61
    }
62
}
63

src/Query/ScriptQuery.php 1 location

@@ 22-59 (lines=38) @@
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html
21
 */
22
class ScriptQuery implements BuilderInterface
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var string
28
     */
29
    private $script;
30
31
    /**
32
     * @param string $script     Script
33
     * @param array  $parameters Optional parameters
34
     */
35
    public function __construct($script, array $parameters = [])
36
    {
37
        $this->script = $script;
38
        $this->setParameters($parameters);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getType()
45
    {
46
        return 'script';
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function toArray()
53
    {
54
        $query = ['inline' => $this->script];
55
        $output = $this->processArray($query);
56
57
        return [$this->getType() => ['script' => $output]];
58
    }
59
}
60

src/Query/Span/SpanMultiTermQuery.php 1 location

@@ 22-64 (lines=43) @@
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html
21
 */
22
class SpanMultiTermQuery implements SpanQueryInterface
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var BuilderInterface
28
     */
29
    private $query;
30
31
    /**
32
     * Accepts one of fuzzy, prefix, term range, wildcard, regexp query.
33
     *
34
     * @param BuilderInterface $query
35
     * @param array            $parameters
36
     */
37
    public function __construct(BuilderInterface $query, array $parameters = [])
38
    {
39
        $this->query = $query;
40
        $this->setParameters($parameters);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getType()
47
    {
48
        return 'span_multi';
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     *
54
     * @throws \InvalidArgumentException
55
     */
56
    public function toArray()
57
    {
58
        $query = [];
59
        $query['match'] = $this->query->toArray();
60
        $output = $this->processArray($query);
61
62
        return [$this->getType() => $output];
63
    }
64
}
65

src/Query/ConstantScoreQuery.php 1 location

@@ 22-62 (lines=41) @@
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
21
 */
22
class ConstantScoreQuery implements BuilderInterface
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var BuilderInterface
28
     */
29
    private $query;
30
31
    /**
32
     * @param BuilderInterface $query
33
     * @param array            $parameters
34
     */
35
    public function __construct(BuilderInterface $query, array $parameters = [])
36
    {
37
        $this->query = $query;
38
        $this->setParameters($parameters);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getType()
45
    {
46
        return 'constant_score';
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function toArray()
53
    {
54
        $query = [
55
            'filter' => $this->query->toArray(),
56
        ];
57
58
        $output = $this->processArray($query);
59
60
        return [$this->getType() => $output];
61
    }
62
}
63

src/Query/QueryStringQuery.php 1 location

@@ 22-62 (lines=41) @@
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
21
 */
22
class QueryStringQuery implements BuilderInterface
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var string The actual query to be parsed.
28
     */
29
    private $query;
30
31
    /**
32
     * @param string $query
33
     * @param array  $parameters
34
     */
35
    public function __construct($query, array $parameters = [])
36
    {
37
        $this->query = $query;
38
        $this->setParameters($parameters);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getType()
45
    {
46
        return 'query_string';
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function toArray()
53
    {
54
        $query = [
55
            'query' => $this->query,
56
        ];
57
58
        $output = $this->processArray($query);
59
60
        return [$this->getType() => $output];
61
    }
62
}
63

src/Query/SimpleQueryStringQuery.php 1 location

@@ 22-62 (lines=41) @@
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
21
 */
22
class SimpleQueryStringQuery implements BuilderInterface
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var string The actual query to be parsed.
28
     */
29
    private $query;
30
31
    /**
32
     * @param string $query
33
     * @param array  $parameters
34
     */
35
    public function __construct($query, array $parameters = [])
36
    {
37
        $this->query = $query;
38
        $this->setParameters($parameters);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getType()
45
    {
46
        return 'simple_query_string';
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function toArray()
53
    {
54
        $query = [
55
            'query' => $this->query,
56
        ];
57
58
        $output = $this->processArray($query);
59
60
        return [$this->getType() => $output];
61
    }
62
}
63