Completed
Pull Request — develop (#63)
by Sam
01:30
created

NestedQuery::getValidScoreModes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 8
loc 8
rs 9.4285

1 Method

Rating   Name   Duplication   Size   Complexity  
A NestedQuery::setPath() 0 4 1
1
<?php namespace Nord\Lumen\Elasticsearch\Search\Query\Joining;
2
3
use Nord\Lumen\Elasticsearch\Search\Query\ScoreMode;
4
5
/**
6
 * Nested query allows to query nested objects / docs (see nested mapping).
7
 *
8
 * The query is executed against the nested objects / docs as if they were indexed as separate docs (they are,
9
 * internally) and resulting in the root parent doc (or parent nested mapping).
10
 *
11
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
12
 */
13
class NestedQuery extends AbstractQuery
14
{
15
    /**
16
     * @var string
17
     */
18
    private $path;
19
20
21
    /**
22
     * @inheritdoc
23
     */
24 View Code Duplication
    public function toArray()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
25
    {
26
        $nested = [
27
            'path'  => $this->getPath(),
28
            'query' => $this->getQuery()->toArray(),
29
        ];
30
31
        $scoreMode = $this->getScoreMode();
32
        if (!is_null($scoreMode)) {
33
            $nested['score_mode'] = $scoreMode;
34
        }
35
36
        return ['nested' => $nested];
37
    }
38
39
    /**
40
     * @param string $path
41
     * @return NestedQuery
42
     */
43
    public function setPath($path)
44
    {
45
        $this->path = $path;
46
        return $this;
47
    }
48
49
50
    /**
51
     * @return string
52
     */
53
    public function getPath()
54
    {
55
        return $this->path;
56
    }
57
}
58