Completed
Pull Request — master (#348)
by
unknown
01:15
created

ParentIdQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 48
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ONGR\ElasticsearchDSL\Query\Joining;
6
7
use ONGR\ElasticsearchDSL\BuilderInterface;
8
use ONGR\ElasticsearchDSL\ParametersTrait;
9
10
/**
11
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-parent-id-query.html
12
 */
13
class ParentIdQuery implements BuilderInterface
14
{
15
    use ParametersTrait;
16
17
    public function __construct(
18
        private string $parentId,
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_PRIVATE, expecting T_VARIABLE
Loading history...
19
        private string $childType,
20
        array $parameters = []
21
    ) {
22
        $this->setParameters($parameters);
23
    }
24
25
    public function getType(): string
26
    {
27
        return 'parent_id';
28
    }
29
30
    public function toArray(): array
31
    {
32
        $query = [
33
            'id' => $this->parentId,
34
            'type' => $this->childType,
35
        ];
36
        $output = $this->processArray($query);
37
38
        return [$this->getType() => $output];
39
    }
40
}
41