Conditions | 9 |
Paths | 2 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function AreRoundTimesValid(RoundTimeCreateModel $model) { |
||
19 | $valid = true; |
||
20 | $errors = array(); |
||
21 | |||
22 | if ($model->isRoundTimesEnabled) { |
||
23 | $roundTimeNumber = 0; |
||
24 | foreach ($model->roundTimes as $roundTime) { |
||
25 | $roundTimeNumber++; |
||
26 | |||
27 | if (empty($roundTime->draft_id) || |
||
28 | empty($roundTime->round_time_seconds)) { |
||
29 | $errors[] = "Round time #$roundTimeNumber has one or more missing fields."; |
||
30 | $valid = false; |
||
31 | } |
||
32 | |||
33 | if ($roundTime->round_time_seconds <= 0) { |
||
34 | $errors[] = "Round time #$roundTimeNumber must have 1 or more seconds specified."; |
||
35 | $valid = false; |
||
36 | } |
||
37 | |||
38 | if (!$roundTime->is_static_time && ($roundTime->draft_round < 1 || $roundTime->draft_round > 30)) { |
||
39 | $errors[] = "Round time #$roundTimeNumber cannot have a round less than 1 or greater than 30."; |
||
40 | $valid = false; |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 | |||
45 | return new PhpDraftResponse($valid, $errors); |
||
46 | } |
||
47 | } |