-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDateTimeFieldMapper.php
More file actions
69 lines (61 loc) · 1.68 KB
/
Copy pathDateTimeFieldMapper.php
File metadata and controls
69 lines (61 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Mapper for mapping data between raw input and a datetime object
*
* @category PHPExif
* @copyright Copyright (c) 2016 Tom Van Herreweghe <tom@theanalogguy.be>
* @license http://github.com/PHPExif/php-exif-exiftool/blob/master/LICENSE MIT License
* @link http://github.com/PHPExif/php-exif-exiftool for the canonical source repository
* @package Exiftool
*/
namespace PHPExif\Adapter\Exiftool\Reader\Mapper\Exif;
use PHPExif\Common\Data\ExifInterface;
use PHPExif\Common\Mapper\FieldMapper;
use PHPExif\Common\Mapper\GuardInvalidArgumentsForExifTrait;
use \DateTimeImmutable;
/**
* Mapper
*
* @category PHPExif
* @package Exiftool
*/
class DateTimeFieldMapper implements FieldMapper
{
use GuardInvalidArgumentsForExifTrait;
use ValidKeysTrait;
/**
* @var array
*/
private $validKeys = [
'system:filemodifydate',
'composite:subsecdatetimeoriginal',
'composite:subsecmodifydate',
'exififd:datetimeoriginal',
'exififd:createdate',
'ifd0:modifydate',
];
/**
* {@inheritDoc}
*/
public function getSupportedFields()
{
return array(
DateTimeImmutable::class,
);
}
/**
* {@inheritDoc}
*/
public function mapField($field, array $input, &$output)
{
$this->guardInvalidArguments($field, $input, $output);
foreach ($this->validKeys as $key) {
if (!array_key_exists($key, $input)) {
continue;
}
$datetimeOriginal = new DateTimeImmutable($input[$key]);
$output = $output->withCreationDate($datetimeOriginal);
break;
}
}
}