@@ -25,8 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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'); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | private $allowSkip = false; |
22 | 22 | |
23 | - function __construct(string $name = ''){ |
|
23 | + function __construct(string $name = '') { |
|
24 | 24 | $this->name = $name; |
25 | 25 | } |
26 | 26 | public function __toString() { |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | public function getCategoryWait() { |
56 | 56 | return $this->expectedCategoryWait; |
57 | 57 | } |
58 | - public function getTournamentTime(){ |
|
58 | + public function getTournamentTime() { |
|
59 | 59 | $games = count($this->getGames()); |
60 | 60 | return $games*$this->expectedPlay+$games*$this->expectedGameWait+count($this->getRounds())*$this->expectedRoundWait+count($this->getCategories())*$this->expectedCategoryWait; |
61 | 61 | } |
62 | 62 | |
63 | - public function allowSkip(){ |
|
63 | + public function allowSkip() { |
|
64 | 64 | $this->allowSkip = true; |
65 | 65 | return $this; |
66 | 66 | } |
67 | - public function disallowSkip(){ |
|
67 | + public function disallowSkip() { |
|
68 | 68 | $this->allowSkip = false; |
69 | 69 | return $this; |
70 | 70 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | return $this->allowSkip; |
77 | 77 | } |
78 | 78 | |
79 | - public function addCategory(Category ...$categories){ |
|
79 | + public function addCategory(Category ...$categories) { |
|
80 | 80 | foreach ($categories as $category) { |
81 | 81 | if ($category instanceof Category) $this->categories[] = $category; |
82 | 82 | else throw new \Exception('Trying to add category which is not an instance of the Category class.'); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | public function addTeam(Team ...$teams) { |
119 | 119 | foreach ($teams as $team) { |
120 | - if ($team instanceof Team) { |
|
120 | + if ($team instanceof Team) { |
|
121 | 121 | $this->teams[] = $team; |
122 | 122 | continue; |
123 | 123 | } |