Completed
Push — master ( 9552d6...4b2b1b )
by Simonas
08:12
created

ParentIdQuery::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ONGR\ElasticsearchDSL\Query\Joining;
4
5
use ONGR\ElasticsearchDSL\BuilderInterface;
6
use ONGR\ElasticsearchDSL\ParametersTrait;
7
8
/**
9
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-parent-id-query.html
10
 */
11
class ParentIdQuery implements BuilderInterface
12
{
13
    use ParametersTrait;
14
15
    /**
16
     * @var string
17
     */
18
    private $childType;
19
20
    /**
21
     * @var string
22
     */
23
    private $parentId;
24
25
    /**
26
     * @param string $parentId
27
     * @param string $childType
28
     * @param array  $parameters
29
     */
30
    public function __construct($parentId, string $childType, array $parameters = [])
31
    {
32
        $this->childType = $childType;
33
        $this->parentId = $parentId;
34
        $this->setParameters($parameters);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getType()
41
    {
42
        return 'parent_id';
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function toArray()
49
    {
50
        $query = [
51
            'id' => $this->parentId,
52
            'type' => $this->childType,
53
        ];
54
        $output = $this->processArray($query);
55
56
        return [$this->getType() => $output];
57
    }
58
}
59