jsonSerializeAsSimpleOrExtended()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace olvlvl\ElasticsearchDSL\Query\Helpers;
4
5
trait JsonSerializeAsSimpleOrExtended
6
{
7
	private function jsonSerializeAsSimpleOrExtended(string $property = 'value')
8
	{
9
		$options = parent::jsonSerialize();
10
11
		if ($options) {
12
			return [ static::NAME => [ $this->field => [ $property => $this->$property ] + $options ] ];
0 ignored issues
show
Bug introduced by
The constant olvlvl\ElasticsearchDSL\...sSimpleOrExtended::NAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
13
		}
14
15
		return [ static::NAME => [ $this->field => $this->$property ] ];
16
	}
17
}
18