|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Mapper for mapping data between raw input and a Height 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\Dimensions; |
|
16
|
|
|
use PHPExif\Common\Data\ValueObject\Height; |
|
17
|
|
|
use PHPExif\Common\Data\ValueObject\Width; |
|
18
|
|
|
use PHPExif\Common\Mapper\FieldMapper; |
|
19
|
|
|
use PHPExif\Common\Mapper\GuardInvalidArgumentsForExifTrait; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Mapper |
|
23
|
|
|
* |
|
24
|
|
|
* @category PHPExif |
|
25
|
|
|
* @package Native |
|
26
|
|
|
*/ |
|
27
|
|
|
class DimensionsFieldMapper implements FieldMapper |
|
28
|
|
|
{ |
|
29
|
|
|
use GuardInvalidArgumentsForExifTrait; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritDoc} |
|
33
|
|
|
*/ |
|
34
|
|
|
public function getSupportedFields() |
|
35
|
|
|
{ |
|
36
|
|
|
return array( |
|
37
|
|
|
Dimensions::class, |
|
38
|
|
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritDoc} |
|
43
|
|
|
*/ |
|
44
|
|
|
public function mapField($field, array $input, &$output) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->guardInvalidArguments($field, $input, $output); |
|
47
|
|
|
|
|
48
|
|
|
if (!array_key_exists('computed', $input)) { |
|
49
|
|
|
return; |
|
50
|
|
|
} |
|
51
|
|
|
$input = $input['computed']; |
|
52
|
|
|
|
|
53
|
|
|
if (!(array_key_exists('width', $input) && array_key_exists('height', $input))) { |
|
54
|
|
|
return; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$dimensions = new Dimensions( |
|
58
|
|
|
Width::pixels((int) $input['width']), |
|
59
|
|
|
Height::pixels((int) $input['height']) |
|
60
|
|
|
); |
|
61
|
|
|
|
|
62
|
|
|
$output = $output->withDimensions($dimensions); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|