Check   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 16
c 1
b 0
f 0
dl 0
loc 45
ccs 8
cts 14
cp 0.5714
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A allEmpty() 0 11 3
A allPresent() 0 16 5
1
<?php
2
3
namespace ElegantMedia\PHPToolkit;
4
5
class Check
6
{
7
	/**
8
	 * Check if all values are empty
9
	 * http://stackoverflow.com/questions/4993104/using-ifempty-with-multiple-variables-not-in-an-array.
10
	 *
11
	 * Eg
12
	 * Util::all_empty($var, $var2, $var3);
13
	 *
14
	 * @return bool
15
	 */
16
	public static function allEmpty(): bool
17
	{
18
		foreach (func_get_args() as $arg) {
19
			if (empty($arg)) {
20
				continue;
21
			} else {
22
				return false;
23
			}
24
		}
25
26
		return true;
27
	}
28
29
	/**
30
	 * Check all values are present (i.e. Not empty).
31
	 *
32
	 * @return bool
33
	 */
34
	public static function allPresent(): bool
35
	{
36
		$args = func_get_args();
37
		if (func_num_args() === 1 && is_array($args[0])) {
38 15
			$args = $args[0];
39
		}
40 15
41 15
		foreach ($args as $arg) {
42 15
			if (!empty($arg)) {
43
				continue;
44
			} else {
45 15
				return false;
46 15
			}
47 15
		}
48
49 12
		return true;
50
	}
51
}
52