| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public static function getValueFromArray(array $sourceData, $key, $isRequired, $defaultValue) |
||
| 17 | { |
||
| 18 | if (array_key_exists($key, $sourceData)) { |
||
| 19 | return $sourceData[$key]; |
||
| 20 | } |
||
| 21 | |||
| 22 | if ($isRequired) { |
||
| 23 | throw new HttpException( |
||
| 24 | sprintf('missing required field "%s"', $key), |
||
| 25 | 400 |
||
| 26 | ); |
||
| 27 | } |
||
| 28 | |||
| 29 | return $defaultValue; |
||
| 30 | } |
||
| 31 | } |
||
| 32 |