Completed
Push — develop ( b42da4...c15277 )
by Sam
13s
created

HasParentQuery::getValidScoreModes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Nord\Lumen\Elasticsearch\Search\Query\Joining;
2
3
use Nord\Lumen\Elasticsearch\Search\Query\ScoreMode;
4
use Nord\Lumen\Elasticsearch\Search\Query\Traits\HasType;
5
6
/**
7
 * The has_parent query accepts a query and a parent type. The query is executed in the parent document space, which is
8
 * specified by the parent type. This query returns child documents which associated parents have matched. For the rest
9
 * has_parent query has the same options and works in the same manner as the has_child query.
10
 *
11
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html
12
 */
13
class HasParentQuery extends AbstractQuery
14
{
15
    use HasType;
16
17
18
    /**
19
     * @inheritdoc
20
     */
21 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...
22
    {
23
        $hasParent = [
24
            'parent_type'  => $this->getType(),
25
            'query'        => $this->getQuery()->toArray(),
26
        ];
27
28
        $scoreMode = $this->getScoreMode();
29
        if (!is_null($scoreMode)) {
30
            $hasParent['score_mode'] = $scoreMode;
31
        }
32
33
        return ['has_parent' => $hasParent];
34
    }
35
}
36