Helpers   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A filter_merge() 0 3 1
A filter_not_null() 0 4 1
A merge_and_prefer_single() 0 3 1
A prefer_single() 0 7 2
1
<?php
2
3
namespace olvlvl\ElasticsearchDSL;
4
5
class Helpers
6
{
7
	static public function filter_not_null(array $input)
8
	{
9
		return array_filter($input, function ($value) {
10
			return !is_null($value);
11
		});
12
	}
13
14
	static public function filter_merge(...$input)
15
	{
16
		return array_values(array_filter(array_merge(...$input)));
17
	}
18
19
	static public function prefer_single(array $input)
20
	{
21
		if (count($input) !== 1) {
22
			return $input;
23
		}
24
25
		return reset($input);
26
	}
27
28
	static public function merge_and_prefer_single(...$input)
29
	{
30
		return Helpers::prefer_single(self::filter_merge(...$input));
31
	}
32
}
33