@@ 32-83 (lines=52) @@ | ||
29 | * @category PHPExif |
|
30 | * @package Native |
|
31 | */ |
|
32 | class ExifMapper implements ArrayMapper, FieldMapper |
|
33 | { |
|
34 | use FieldMapperTrait; |
|
35 | ||
36 | /** |
|
37 | * {@inheritDoc} |
|
38 | */ |
|
39 | public function getSupportedFields() |
|
40 | { |
|
41 | return array( |
|
42 | Exif::class, |
|
43 | ); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * {@inheritDoc} |
|
48 | */ |
|
49 | public function mapArray(array $input, &$output) |
|
50 | { |
|
51 | if (!($output instanceof ExifInterface)) { |
|
52 | throw UnsupportedOutputException::forOutput($output); |
|
53 | } |
|
54 | ||
55 | $fieldMappers = $this->getFieldMappers(); |
|
56 | ||
57 | foreach ($fieldMappers as $field => $fieldMapper) { |
|
58 | $fieldMapper->mapField( |
|
59 | $field, |
|
60 | $input, |
|
61 | $output |
|
62 | ); |
|
63 | } |
|
64 | } |
|
65 | ||
66 | /** |
|
67 | * {@inheritDoc} |
|
68 | */ |
|
69 | public function mapField($field, array $input, &$output) |
|
70 | { |
|
71 | if (!in_array($field, $this->getSupportedFields())) { |
|
72 | throw UnsupportedFieldException::forField($field); |
|
73 | } |
|
74 | ||
75 | if (!($output instanceof MetadataInterface)) { |
|
76 | throw UnsupportedOutputException::forOutput($output); |
|
77 | } |
|
78 | ||
79 | $exif = $output->getExif(); |
|
80 | $this->mapArray($input, $exif); |
|
81 | $output = $output->withExif($exif); |
|
82 | } |
|
83 | } |
|
84 |
@@ 32-83 (lines=52) @@ | ||
29 | * @category PHPExif |
|
30 | * @package Native |
|
31 | */ |
|
32 | class IptcMapper implements ArrayMapper, FieldMapper |
|
33 | { |
|
34 | use FieldMapperTrait; |
|
35 | ||
36 | /** |
|
37 | * {@inheritDoc} |
|
38 | */ |
|
39 | public function getSupportedFields() |
|
40 | { |
|
41 | return array( |
|
42 | Iptc::class, |
|
43 | ); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * {@inheritDoc} |
|
48 | */ |
|
49 | public function mapArray(array $input, &$output) |
|
50 | { |
|
51 | if (!($output instanceof IptcInterface)) { |
|
52 | throw UnsupportedOutputException::forOutput($output); |
|
53 | } |
|
54 | ||
55 | $fieldMappers = $this->getFieldMappers(); |
|
56 | ||
57 | foreach ($fieldMappers as $field => $fieldMapper) { |
|
58 | $fieldMapper->mapField( |
|
59 | $field, |
|
60 | $input, |
|
61 | $output |
|
62 | ); |
|
63 | } |
|
64 | } |
|
65 | ||
66 | /** |
|
67 | * {@inheritDoc} |
|
68 | */ |
|
69 | public function mapField($field, array $input, &$output) |
|
70 | { |
|
71 | if (!in_array($field, $this->getSupportedFields())) { |
|
72 | throw UnsupportedFieldException::forField($field); |
|
73 | } |
|
74 | ||
75 | if (!($output instanceof MetadataInterface)) { |
|
76 | throw UnsupportedOutputException::forOutput($output); |
|
77 | } |
|
78 | ||
79 | $iptc = $output->getIptc(); |
|
80 | $this->mapArray($input, $iptc); |
|
81 | $output = $output->withIptc($iptc); |
|
82 | } |
|
83 | } |
|
84 |