| Conditions | 6 |
| Paths | 32 |
| Total Lines | 31 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function AreDepthChartPositionsValid(DepthChartPositionCreateModel $depthChartPositionCreateModel) { |
||
| 29 | $valid = true; |
||
| 30 | $errors = array(); |
||
| 31 | |||
| 32 | if (count($depthChartPositionCreateModel->positions) !== count(array_unique($depthChartPositionCreateModel->positions))) { |
||
| 33 | $valid = false; |
||
| 34 | $errors[] = "One or more of the positions are not unique."; |
||
| 35 | } |
||
| 36 | |||
| 37 | $rounds = 0; |
||
| 38 | |||
| 39 | foreach ($depthChartPositionCreateModel->positions as $depthChartPosition) { |
||
| 40 | $rounds += (int)$depthChartPosition->slots; |
||
| 41 | } |
||
| 42 | |||
| 43 | if ($rounds == 0) { |
||
|
|
|||
| 44 | $valid = false; |
||
| 45 | $errors[] = "The depth chart positions must specify at least 1 slot"; |
||
| 46 | } |
||
| 47 | |||
| 48 | if ($rounds > 30) { |
||
| 49 | $valid = false; |
||
| 50 | $errors[] = "The depth chart positions cannot specify more than 30 slots in total."; |
||
| 51 | } |
||
| 52 | |||
| 53 | if (count($depthChartPositionCreateModel->positions) > 30) { |
||
| 54 | $valid = false; |
||
| 55 | $errors[] = "Too many depth chart positions have been provided - 30 is the maximum."; |
||
| 56 | } |
||
| 57 | |||
| 58 | return $this->app['phpdraft.ResponseFactory']($valid, $errors); |
||
| 59 | } |
||
| 60 | } |