JoiningQueries::jsonSerializeJoiningQueries()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace olvlvl\ElasticsearchDSL\Query;
4
5
use olvlvl\ElasticsearchDSL\Helpers;
6
use olvlvl\ElasticsearchDSL\Query\Joining\NestedQuery;
7
8
trait JoiningQueries
9
{
10
	/**
11
	 * @var NestedQuery[]
12
	 */
13
	private $nested = [];
14
15
	public function nested(string $path, callable $config = null): NestedQuery
16
	{
17
		$this->nested[] = $q = new NestedQuery($path);
18
19
		if ($config) {
20
			$config($q);
21
		}
22
23
		return $q;
24
	}
25
26
	protected function jsonSerializeJoiningQueries(): array
27
	{
28
		return Helpers::filter_merge(
29
			$this->nested
30
		);
31
	}
32
}
33