Completed
Push — master ( c155af...426474 )
by Tomáš
06:03
created
src/classes/class_filter.php 1 patch
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
 			if (gettype($filter) === 'array') {
26 26
 				$this->filterMulti($teams, $filter, $key);
27 27
 				continue;
28
-			}
29
-			elseif ($filter instanceof TeamFilter) {
28
+			} elseif ($filter instanceof TeamFilter) {
30 29
 				$teams = array_filter($teams, function($team) use ($filter) {return $filter->validate($team, $this->group->id, 'sum', $this->group); });
31 30
 				continue;
32 31
 			}
@@ -39,12 +38,18 @@  discard block
 block discarded – undo
39 38
 		switch (strtolower($how)) {
40 39
 			case 'and':
41 40
 				foreach ($teams as $tkey => $team) {
42
-					if (!$this->filterAnd($team, $filters)) unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
41
+					if (!$this->filterAnd($team, $filters)) {
42
+						unset($teams[$tkey]);
43
+					}
44
+					// IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
43 45
 				}
44 46
 				return true;
45 47
 			case 'or':
46 48
 				foreach ($teams as $tkey => $team) {
47
-					if (!$this->filterOr($team, $filters)) unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
49
+					if (!$this->filterOr($team, $filters)) {
50
+						unset($teams[$tkey]);
51
+					}
52
+					// IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
48 53
 				}
49 54
 				return true;
50 55
 		}
@@ -56,19 +61,24 @@  discard block
 block discarded – undo
56 61
 			if (gettype($value) === 'array') {
57 62
 				switch (strtolower($key)) {
58 63
 					case 'and':
59
-						if ($this->filterAnd($team, $value)) return false;
64
+						if ($this->filterAnd($team, $value)) {
65
+							return false;
66
+						}
60 67
 						break;
61 68
 					case 'or':
62
-						if ($this->filterOr($team, $value)) return false;
69
+						if ($this->filterOr($team, $value)) {
70
+							return false;
71
+						}
63 72
 						break;
64 73
 					default:
65 74
 						throw new \Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
66 75
 						break;
67 76
 				}
68 77
 				continue;
69
-			}
70
-			elseif ($value instanceof TeamFilter) {
71
-				if (!$value->validate($team, $this->group->id, 'sum', $this->group)) return false;
78
+			} elseif ($value instanceof TeamFilter) {
79
+				if (!$value->validate($team, $this->group->id, 'sum', $this->group)) {
80
+					return false;
81
+				}
72 82
 				continue;
73 83
 			}
74 84
 			throw new \Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
@@ -80,19 +90,24 @@  discard block
 block discarded – undo
80 90
 			if (gettype($value) === 'array') {
81 91
 				switch (strtolower($key)) {
82 92
 					case 'and':
83
-						if ($this->filterAnd($team, $value)) return true;
93
+						if ($this->filterAnd($team, $value)) {
94
+							return true;
95
+						}
84 96
 						break;
85 97
 					case 'or':
86
-						if ($this->filterOr($team, $value)) return true;
98
+						if ($this->filterOr($team, $value)) {
99
+							return true;
100
+						}
87 101
 						break;
88 102
 					default:
89 103
 						throw new \Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
90 104
 						break;
91 105
 				}
92 106
 				continue;
93
-			}
94
-			elseif ($value instanceof TeamFilter) {
95
-				if (!$value->validate($team, $this->group->id, 'sum', $this->group)) return true;
107
+			} elseif ($value instanceof TeamFilter) {
108
+				if (!$value->validate($team, $this->group->id, 'sum', $this->group)) {
109
+					return true;
110
+				}
96 111
 				continue;
97 112
 			}
98 113
 			throw new \Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
Please login to merge, or discard this patch.