| @@ 25-65 (lines=41) @@ | ||
| 22 | * @category PHPExif |
|
| 23 | * @package Exiftool |
|
| 24 | */ |
|
| 25 | class ApertureFieldMapper implements FieldMapper |
|
| 26 | { |
|
| 27 | use GuardInvalidArgumentsForExifTrait; |
|
| 28 | use ValidKeysTrait; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @var array |
|
| 32 | */ |
|
| 33 | private $validKeys = [ |
|
| 34 | 'composite:aperture', |
|
| 35 | 'exififd:fnumber', |
|
| 36 | 'exififd:aperturevalue', |
|
| 37 | ]; |
|
| 38 | ||
| 39 | /** |
|
| 40 | * {@inheritDoc} |
|
| 41 | */ |
|
| 42 | public function getSupportedFields() |
|
| 43 | { |
|
| 44 | return array( |
|
| 45 | Aperture::class, |
|
| 46 | ); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * {@inheritDoc} |
|
| 51 | */ |
|
| 52 | public function mapField($field, array $input, &$output) |
|
| 53 | { |
|
| 54 | $this->guardInvalidArguments($field, $input, $output); |
|
| 55 | ||
| 56 | foreach ($this->validKeys as $key) { |
|
| 57 | if (!array_key_exists($key, $input)) { |
|
| 58 | continue; |
|
| 59 | } |
|
| 60 | ||
| 61 | $aperture = new Aperture($input[$key]); |
|
| 62 | $output = $output->withAperture($aperture); |
|
| 63 | } |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| @@ 25-65 (lines=41) @@ | ||
| 22 | * @category PHPExif |
|
| 23 | * @package Exiftool |
|
| 24 | */ |
|
| 25 | class ExposureTimeFieldMapper implements FieldMapper |
|
| 26 | { |
|
| 27 | use GuardInvalidArgumentsForExifTrait; |
|
| 28 | use ValidKeysTrait; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @var array |
|
| 32 | */ |
|
| 33 | private $validKeys = [ |
|
| 34 | 'exififd:exposuretime', |
|
| 35 | 'composite:shutterspeed', |
|
| 36 | ]; |
|
| 37 | ||
| 38 | /** |
|
| 39 | * {@inheritDoc} |
|
| 40 | */ |
|
| 41 | public function getSupportedFields() |
|
| 42 | { |
|
| 43 | return array( |
|
| 44 | ExposureTime::class, |
|
| 45 | ); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * {@inheritDoc} |
|
| 50 | */ |
|
| 51 | public function mapField($field, array $input, &$output) |
|
| 52 | { |
|
| 53 | $this->guardInvalidArguments($field, $input, $output); |
|
| 54 | ||
| 55 | foreach ($this->validKeys as $key) { |
|
| 56 | if (!array_key_exists($key, $input)) { |
|
| 57 | continue; |
|
| 58 | } |
|
| 59 | ||
| 60 | $shutterSpeed = new ExposureTime($input[$key]); |
|
| 61 | $output = $output->withExposureTime($shutterSpeed); |
|
| 62 | break; |
|
| 63 | } |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| @@ 25-65 (lines=41) @@ | ||
| 22 | * @category PHPExif |
|
| 23 | * @package Exiftool |
|
| 24 | */ |
|
| 25 | class FilenameFieldMapper implements FieldMapper |
|
| 26 | { |
|
| 27 | use GuardInvalidArgumentsForExifTrait; |
|
| 28 | use ValidKeysTrait; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @var array |
|
| 32 | */ |
|
| 33 | private $validKeys = [ |
|
| 34 | 'sourcefile', |
|
| 35 | 'system:filename', |
|
| 36 | ]; |
|
| 37 | ||
| 38 | /** |
|
| 39 | * {@inheritDoc} |
|
| 40 | */ |
|
| 41 | public function getSupportedFields() |
|
| 42 | { |
|
| 43 | return array( |
|
| 44 | Filename::class, |
|
| 45 | ); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * {@inheritDoc} |
|
| 50 | */ |
|
| 51 | public function mapField($field, array $input, &$output) |
|
| 52 | { |
|
| 53 | $this->guardInvalidArguments($field, $input, $output); |
|
| 54 | ||
| 55 | foreach ($this->validKeys as $key) { |
|
| 56 | if (!array_key_exists($key, $input)) { |
|
| 57 | continue; |
|
| 58 | } |
|
| 59 | ||
| 60 | $filename = new Filename($input[$key]); |
|
| 61 | $output = $output->withFilename($filename); |
|
| 62 | break; |
|
| 63 | } |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||