Completed
Pull Request — develop (#2)
by Tom Van
03:06
created

ExposureTimeFieldMapper::getSupportedFields()   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 0
1
<?php
2
/**
3
 * Mapper for mapping data between raw input and a ExposureTime VO
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\Mapper\Exif;
13
14
use PHPExif\Common\Data\ExifInterface;
15
use PHPExif\Common\Data\ValueObject\ExposureTime;
16
use PHPExif\Common\Mapper\FieldMapper;
17
use PHPExif\Common\Mapper\GuardInvalidArgumentsForExifTrait;
18
19
/**
20
 * Mapper
21
 *
22
 * @category    PHPExif
23
 * @package     Common
24
 */
25
class ExposureTimeFieldMapper implements FieldMapper
26
{
27
    use GuardInvalidArgumentsForExifTrait;
28
29
    /**
30
     * @var array
31
     */
32
    private $validKeys = [
33
        'exififd:exposuretime',
34
        'composite:shutterspeed',
35
    ];
36
37
    /**
38
     * Getter for validKeys
39
     *
40
     * @return array
41
     */
42
    public function getValidKeys()
43
    {
44
        return $this->validKeys;
45
    }
46
47
    /**
48
     * Setter for validKeys
49
     *
50
     * @param array $validKeys
51
     */
52
    public function setValidKeys(array $validKeys)
53
    {
54
        $this->validKeys = $validKeys;
55
    }
56
57
    /**
58
     * {@inheritDoc}
59
     */
60
    public function getSupportedFields()
61
    {
62
        return array(
63
            ExposureTime::class,
64
        );
65
    }
66
67
    /**
68
     * {@inheritDoc}
69
     */
70 View Code Duplication
    public function mapField($field, array $input, &$output)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        $this->guardInvalidArguments($field, $input, $output);
73
74
        foreach ($this->validKeys as $key) {
75
            if (!array_key_exists($key, $input)) {
76
                continue;
77
            }
78
79
            $shutterSpeed = new ExposureTime($input[$key]);
80
            $output = $output->withExposureTime($shutterSpeed);
81
            break;
82
        }
83
    }
84
}
85