JoiningQueries   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerializeJoiningQueries() 0 4 1
A nested() 0 9 2
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