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