Completed
Pull Request — develop (#2)
by Tom Van
05:00
created

Mapper::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/**
3
 * Mapper for mapping data between raw input and Data classes
4
 *
5
 * @category    PHPExif
6
 * @copyright   Copyright (c) 2016 Tom Van Herreweghe <[email protected]>
7
 * @license     http://github.com/PHPExif/php-exif-exiftool/blob/master/LICENSE MIT License
8
 * @link        http://github.com/PHPExif/php-exif-exiftool for the canonical source repository
9
 * @package     Exiftool
10
 */
11
12
namespace PHPExif\Adapter\Exiftool\Reader;
13
14
use PHPExif\Common\Adapter\MapperInterface;
15
use PHPExif\Common\Data\MetadataInterface;
16
use PHPExif\Common\Mapper\ArrayMapper;
17
use PHPExif\Common\Mapper\FieldMapperTrait;
18
19
/**
20
 * Mapper
21
 *
22
 * Maps the array of exif & iptc data onto the
23
 * correct fields of given MetadataInterface object
24
 *
25
 * @category    PHPExif
26
 * @package     Exiftool
27
 */
28
class Mapper implements MapperInterface, ArrayMapper
29
{
30
    use FieldMapperTrait;
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    public function map(array $input, MetadataInterface &$output)
36
    {
37
        $this->mapArray($input, $output);
38
39
        $output->setRawData($input);
40
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45
    public function mapArray(array $input, &$output)
46
    {
47
        $mappers = $this->getFieldMappers();
48
49
        foreach ($mappers as $field => $mapper) {
50
            $mapper->mapField($field, $input, $output);
51
        }
52
    }
53
}
54