Completed
Push — master ( aee63e...997989 )
by Nicolas
02:11
created

ParentId::setIgnoreUnmapped()   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 1
1
<?php
2
3
namespace Elastica\Query;
4
5
/**
6
 * ParentId query.
7
 *
8
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-parent-id-query.html
9
 */
10
class ParentId extends AbstractQuery
11
{
12
    /**
13
     * ParentId constructor.
14
     *
15
     * @param string $type           Name of the child relationship mapped for the join field
16
     * @param string $id             ID of the parent document. The query will return child documents of this parent document.
17
     * @param bool   $ignoreUnmapped Indicates whether to ignore an unmapped type and not return any documents instead of an error. Defaults to false.
18
     */
19
    public function __construct(string $type, string $id, bool $ignoreUnmapped = false)
20
    {
21
        $this->setRelationshipType($type);
22
        $this->setId($id);
23
        $this->setIgnoreUnmapped($ignoreUnmapped);
24
    }
25
26
    /**
27
     * @param string $type
28
     */
29
    private function setRelationshipType(string $type)
30
    {
31
        $this->setParam('type', $type);
32
    }
33
34
    /**
35
     * @param string $id
36
     */
37
    private function setId(string $id)
38
    {
39
        $this->setParam('id', $id);
40
    }
41
42
    /**
43
     * @param bool $ignoreUnmapped
44
     */
45
    private function setIgnoreUnmapped(bool $ignoreUnmapped = false)
46
    {
47
        $this->setParam('ignore_unmapped', $ignoreUnmapped);
48
    }
49
}
50