@@ 289-296 (lines=8) @@ | ||
286 | * |
|
287 | * @throws MissingArgumentException if a required parameter is missing |
|
288 | */ |
|
289 | protected function validateRequiredParameters(array $required, array $params) |
|
290 | { |
|
291 | foreach ($required as $param) { |
|
292 | if (!isset($params[$param])) { |
|
293 | throw new MissingArgumentException(sprintf('The "%s" parameter is required.', $param)); |
|
294 | } |
|
295 | } |
|
296 | } |
|
297 | ||
298 | /** |
|
299 | * Validate allowed parameters array |
|
@@ 341-353 (lines=13) @@ | ||
338 | * |
|
339 | * @throws MissingArgumentException |
|
340 | */ |
|
341 | protected function validateAtLeastOneOf(array $atLeastOneOf, array $params) |
|
342 | { |
|
343 | foreach ($atLeastOneOf as $param) { |
|
344 | if (isset($params[$param])) { |
|
345 | return true; |
|
346 | } |
|
347 | } |
|
348 | ||
349 | throw new MissingArgumentException(sprintf( |
|
350 | 'You need to provide at least one of the following parameters "%s".', |
|
351 | implode('", "', $atLeastOneOf) |
|
352 | )); |
|
353 | } |
|
354 | } |
|
355 |