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

ParentId   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setId() 0 4 1
A setIgnoreUnmapped() 0 4 1
A setRelationshipType() 0 4 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