BoolQueries   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerializeBoolQueries() 0 4 1
A get_bool() 0 5 2
A bool() 0 5 1
1
<?php
2
3
namespace olvlvl\ElasticsearchDSL\Query;
4
5
use olvlvl\ElasticsearchDSL\Helpers;
6
use olvlvl\ElasticsearchDSL\Query\Compound\BoolQuery;
7
8
trait BoolQueries
9
{
10
	/**
11
	 * @var BoolQuery[]
12
	 */
13
	private $bool_queries = [];
14
15
	protected function get_bool()
16
	{
17
		$query = reset($this->bool_queries);
18
19
		return $query ? $query : $this->bool();
20
	}
21
22
	public function bool(): BoolQuery
23
	{
24
		$this->bool_queries[] = $query = new BoolQuery();
25
26
		return $query;
27
	}
28
29
	protected function jsonSerializeBoolQueries()
30
	{
31
		return Helpers::filter_merge(
32
			$this->bool_queries
33
		);
34
	}
35
}
36