| @@ 25-54 (lines=30) @@ | ||
| 22 | * @category PHPExif |
|
| 23 | * @package Common |
|
| 24 | */ |
|
| 25 | trait GuardInvalidArgumentsForExifTrait |
|
| 26 | { |
|
| 27 | /** |
|
| 28 | * Guard function for invalid arguments |
|
| 29 | * |
|
| 30 | * @codeCoverageIgnore |
|
| 31 | * |
|
| 32 | * @param string $field |
|
| 33 | * @param array $input |
|
| 34 | * @param object $output |
|
| 35 | * |
|
| 36 | * @throws UnsupportedFieldException when asked to map an unsupported field |
|
| 37 | * @throws UnsupportedOutputException when asked to map data on an unsupported output object |
|
| 38 | * |
|
| 39 | * @return void |
|
| 40 | */ |
|
| 41 | private function guardInvalidArguments($field, array $input, $output) |
|
| 42 | { |
|
| 43 | if (!in_array($field, $this->getSupportedFields())) { |
|
| 44 | throw UnsupportedFieldException::forField($field); |
|
| 45 | } |
|
| 46 | ||
| 47 | if (!($output instanceof ExifInterface)) { |
|
| 48 | throw UnsupportedOutputException::forOutput($output); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * {@inheritDoc} |
|
| 54 | */ |
|
| 55 | abstract public function getSupportedFields(); |
|
| 56 | } |
|
| 57 | ||
| @@ 25-54 (lines=30) @@ | ||
| 22 | * @category PHPExif |
|
| 23 | * @package Common |
|
| 24 | */ |
|
| 25 | trait GuardInvalidArgumentsForIptcTrait |
|
| 26 | { |
|
| 27 | /** |
|
| 28 | * Guard function for invalid arguments |
|
| 29 | * |
|
| 30 | * @codeCoverageIgnore |
|
| 31 | * |
|
| 32 | * @param string $field |
|
| 33 | * @param array $input |
|
| 34 | * @param object $output |
|
| 35 | * |
|
| 36 | * @throws UnsupportedFieldException when asked to map an unsupported field |
|
| 37 | * @throws UnsupportedOutputException when asked to map data on an unsupported output object |
|
| 38 | * |
|
| 39 | * @return void |
|
| 40 | */ |
|
| 41 | private function guardInvalidArguments($field, array $input, $output) |
|
| 42 | { |
|
| 43 | if (!in_array($field, $this->getSupportedFields())) { |
|
| 44 | throw UnsupportedFieldException::forField($field); |
|
| 45 | } |
|
| 46 | ||
| 47 | if (!($output instanceof IptcInterface)) { |
|
| 48 | throw UnsupportedOutputException::forOutput($output); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * {@inheritDoc} |
|
| 54 | */ |
|
| 55 | abstract public function getSupportedFields(); |
|
| 56 | } |
|
| 57 | ||