1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Mapper for mapping data between raw input and a HorizontalResolution VO |
4
|
|
|
* |
5
|
|
|
* @link http://github.com/PHPExif/php-exif-native for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2016 Tom Van Herreweghe <[email protected]> |
7
|
|
|
* @license http://github.com/PHPExif/php-exif-native/blob/master/LICENSE MIT License |
8
|
|
|
* @category PHPExif |
9
|
|
|
* @package Native |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace PHPExif\Adapter\Native\Reader\Mapper\Exif; |
13
|
|
|
|
14
|
|
|
use PHPExif\Common\Data\ExifInterface; |
15
|
|
|
use PHPExif\Common\Data\ValueObject\HorizontalResolution; |
16
|
|
|
use PHPExif\Common\Data\ValueObject\VerticalResolution; |
17
|
|
|
use PHPExif\Common\Mapper\FieldMapper; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Mapper |
21
|
|
|
* |
22
|
|
|
* @category PHPExif |
23
|
|
|
* @package Native |
24
|
|
|
*/ |
25
|
|
|
class ResolutionFieldMapper implements FieldMapper |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var array |
29
|
|
|
*/ |
30
|
|
|
protected $map = [ |
31
|
|
|
HorizontalResolution::class => [ |
32
|
|
|
'dataField' => 'XResolution', |
33
|
|
|
'method' => 'withHorizontalResolution', |
34
|
|
|
], |
35
|
|
|
VerticalResolution::class => [ |
36
|
|
|
'dataField' => 'YResolution', |
37
|
|
|
'method' => 'withVerticalResolution', |
38
|
|
|
], |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
use GuardInvalidArgumentsTrait; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritDoc} |
45
|
|
|
*/ |
46
|
|
|
public function getSupportedFields() |
47
|
|
|
{ |
48
|
|
|
return array( |
49
|
|
|
HorizontalResolution::class, |
50
|
|
|
VerticalResolution::class, |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritDoc} |
56
|
|
|
*/ |
57
|
|
|
public function mapField($field, array $input, &$output) |
58
|
|
|
{ |
59
|
|
|
$this->guardInvalidArguments($field, $input, $output); |
60
|
|
|
|
61
|
|
|
$inputField = $this->map[$field]['dataField']; |
62
|
|
|
|
63
|
|
|
if (!array_key_exists($inputField, $input)) { |
64
|
|
|
return; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$valueObject = new $field( |
68
|
|
|
$input[$inputField] |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
$output = $output->{$this->map[$field]['method']}($valueObject); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|