Skip to content

Commit 9f6afbe

Browse files
author
Tom Van Herreweghe
committed
Adhere to PSR/2
Signed-off-by: Tom Van Herreweghe <[email protected]>
1 parent df2b296 commit 9f6afbe

File tree

2 files changed

+47
-31
lines changed

2 files changed

+47
-31
lines changed

lib/PHPExif/Adapter/Exiftool.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Exiftool extends AdapterAbstract
4242

4343
/**
4444
* Setter for the exiftool binary path
45-
*
45+
*
4646
* @param string $path The path to the exiftool binary
4747
* @return \PHPExif\Adapter\Exiftool Current instance
4848
* @throws \InvalidArgumentException When path is invalid
@@ -57,9 +57,9 @@ public function setToolPath($path)
5757
)
5858
);
5959
}
60-
60+
6161
$this->toolPath = $path;
62-
62+
6363
return $this;
6464
}
6565

@@ -70,11 +70,11 @@ public function setNumeric($numeric)
7070
{
7171
$this->numeric = $numeric;
7272
}
73-
73+
7474
/**
7575
* Getter for the exiftool binary path
7676
* Lazy loads the "default" path
77-
*
77+
*
7878
* @return string
7979
*/
8080
public function getToolPath()
@@ -83,10 +83,10 @@ public function getToolPath()
8383
$path = exec('which ' . self::TOOL_NAME);
8484
$this->setToolPath($path);
8585
}
86-
86+
8787
return $this->toolPath;
8888
}
89-
89+
9090
/**
9191
* Reads & parses the EXIF data from given file
9292
*
@@ -104,17 +104,17 @@ public function getExifFromFile($file)
104104
$this->numeric ? ' -n' : ''
105105
)
106106
);
107-
107+
108108
$data = json_decode($result, true);
109109
$mappedData = $this->mapData(reset($data));
110110
$exif = new Exif($mappedData);
111111

112112
return $exif;
113113
}
114-
114+
115115
/**
116116
* Returns the output from given cli command
117-
*
117+
*
118118
* @param string $command
119119
* @return mixed
120120
* @throws RuntimeException If the command can't be executed
@@ -134,20 +134,20 @@ protected function getCliOutput($command)
134134
'Could not open a resource to the exiftool binary'
135135
);
136136
}
137-
137+
138138
$result = stream_get_contents($pipes[1]);
139139
fclose($pipes[0]);
140140
fclose($pipes[1]);
141141
fclose($pipes[2]);
142142

143143
proc_close($process);
144-
144+
145145
return $result;
146146
}
147-
147+
148148
/**
149149
* Maps native data to Exif format
150-
*
150+
*
151151
* @param array $source
152152
* @return array
153153
*/
@@ -170,20 +170,23 @@ public function mapData(array $source)
170170
} elseif (isset($source['Caption-Abstract'])) {
171171
$caption = $source['Caption-Abstract'];
172172
}
173-
173+
174174
return array(
175-
Exif::APERTURE => (!isset($source['Aperture'])) ? false : sprintf('f/%01.1f', $source['Aperture']),
175+
Exif::APERTURE => (!isset($source['Aperture'])) ?
176+
false : sprintf('f/%01.1f', $source['Aperture']),
176177
Exif::AUTHOR => (!isset($source['Artist'])) ? false : $source['Artist'],
177178
Exif::CAMERA => (!isset($source['Model'])) ? false : $source['Model'],
178179
Exif::CAPTION => $caption,
179180
Exif::COLORSPACE => (!isset($source[Exif::COLORSPACE]) ? false : $source[Exif::COLORSPACE]),
180181
Exif::COPYRIGHT => (!isset($source['Copyright'])) ? false : $source['Copyright'],
181-
Exif::CREATION_DATE => (!isset($source['CreateDate'])) ? false : DateTime::createFromFormat('Y:m:d H:i:s', $source['CreateDate']),
182+
Exif::CREATION_DATE => (!isset($source['CreateDate'])) ?
183+
false : DateTime::createFromFormat('Y:m:d H:i:s', $source['CreateDate']),
182184
Exif::CREDIT => (!isset($source['Credit'])) ? false : $source['Credit'],
183185
Exif::EXPOSURE => $exposureTime,
184186
Exif::FILESIZE => (!isset($source[Exif::FILESIZE]) ? false : $source[Exif::FILESIZE]),
185187
Exif::FOCAL_LENGTH => $focalLength,
186-
Exif::FOCAL_DISTANCE => (!isset($source['ApproximateFocusDistance'])) ? false : sprintf('%1$sm', $source['ApproximateFocusDistance']),
188+
Exif::FOCAL_DISTANCE => (!isset($source['ApproximateFocusDistance'])) ?
189+
false : sprintf('%1$sm', $source['ApproximateFocusDistance']),
187190
Exif::HEADLINE => (!isset($source['Headline'])) ? false : $source['Headline'],
188191
Exif::HEIGHT => (!isset($source['ImageHeight'])) ? false : $source['ImageHeight'],
189192
Exif::HORIZONTAL_RESOLUTION => (!isset($source['XResolution'])) ? false : $source['XResolution'],

lib/PHPExif/Adapter/Native.php

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,31 +262,44 @@ public function mapData(array $source)
262262
}
263263

264264
return array(
265-
Exif::APERTURE => (!isset($source[self::SECTION_COMPUTED]['ApertureFNumber'])) ? false : $source[self::SECTION_COMPUTED]['ApertureFNumber'],
265+
Exif::APERTURE => (!isset($source[self::SECTION_COMPUTED]['ApertureFNumber'])) ?
266+
false : $source[self::SECTION_COMPUTED]['ApertureFNumber'],
266267
Exif::AUTHOR => (!isset($source['Artist'])) ? false : $source['Artist'],
267268
Exif::CAMERA => (!isset($source['Model'])) ? false : $source['Model'],
268-
Exif::CAPTION => (!isset($source[self::SECTION_IPTC]['caption'])) ? false : $source[self::SECTION_IPTC]['caption'],
269+
Exif::CAPTION => (!isset($source[self::SECTION_IPTC]['caption'])) ?
270+
false : $source[self::SECTION_IPTC]['caption'],
269271
Exif::COLORSPACE => (!isset($source[Exif::COLORSPACE]) ? false : $source[Exif::COLORSPACE]),
270-
Exif::COPYRIGHT => (!isset($source[self::SECTION_IPTC]['copyright'])) ? false : $source[self::SECTION_IPTC]['copyright'],
271-
Exif::CREATION_DATE => (!isset($source['DateTimeOriginal'])) ? false : DateTime::createFromFormat('Y:m:d H:i:s', $source['DateTimeOriginal']),
272-
Exif::CREDIT => (!isset($source[self::SECTION_IPTC]['credit'])) ? false : $source[self::SECTION_IPTC]['credit'],
272+
Exif::COPYRIGHT => (!isset($source[self::SECTION_IPTC]['copyright'])) ?
273+
false : $source[self::SECTION_IPTC]['copyright'],
274+
Exif::CREATION_DATE => (!isset($source['DateTimeOriginal'])) ?
275+
false : DateTime::createFromFormat('Y:m:d H:i:s', $source['DateTimeOriginal']),
276+
Exif::CREDIT => (!isset($source[self::SECTION_IPTC]['credit'])) ?
277+
false : $source[self::SECTION_IPTC]['credit'],
273278
Exif::EXPOSURE => $exposureTime,
274279
Exif::FILESIZE => (!isset($source[Exif::FILESIZE]) ? false : $source[Exif::FILESIZE]),
275280
Exif::FOCAL_LENGTH => $focalLength,
276-
Exif::FOCAL_DISTANCE => (!isset($source[self::SECTION_COMPUTED]['FocusDistance'])) ? false : $source[self::SECTION_COMPUTED]['FocusDistance'],
277-
Exif::HEADLINE => (!isset($source[self::SECTION_IPTC]['headline'])) ? false : $source[self::SECTION_IPTC]['headline'],
278-
Exif::HEIGHT => (!isset($source[self::SECTION_COMPUTED]['Height'])) ? false : $source[self::SECTION_COMPUTED]['Height'],
281+
Exif::FOCAL_DISTANCE => (!isset($source[self::SECTION_COMPUTED]['FocusDistance'])) ?
282+
false : $source[self::SECTION_COMPUTED]['FocusDistance'],
283+
Exif::HEADLINE => (!isset($source[self::SECTION_IPTC]['headline'])) ?
284+
false : $source[self::SECTION_IPTC]['headline'],
285+
Exif::HEIGHT => (!isset($source[self::SECTION_COMPUTED]['Height'])) ?
286+
false : $source[self::SECTION_COMPUTED]['Height'],
279287
Exif::HORIZONTAL_RESOLUTION => $horResolution,
280288
Exif::ISO => (!isset($source['ISOSpeedRatings'])) ? false : $source['ISOSpeedRatings'],
281-
Exif::JOB_TITLE => (!isset($source[self::SECTION_IPTC]['jobtitle'])) ? false : $source[self::SECTION_IPTC]['jobtitle'],
282-
Exif::KEYWORDS => (!isset($source[self::SECTION_IPTC]['keywords'])) ? false : $source[self::SECTION_IPTC]['keywords'],
289+
Exif::JOB_TITLE => (!isset($source[self::SECTION_IPTC]['jobtitle'])) ?
290+
false : $source[self::SECTION_IPTC]['jobtitle'],
291+
Exif::KEYWORDS => (!isset($source[self::SECTION_IPTC]['keywords'])) ?
292+
false : $source[self::SECTION_IPTC]['keywords'],
283293
Exif::MIMETYPE => (!isset($source[Exif::MIMETYPE]) ? false : $source[Exif::MIMETYPE]),
284294
Exif::ORIENTATION => (!isset($source[Exif::ORIENTATION]) ? false : $source[Exif::ORIENTATION]),
285295
Exif::SOFTWARE => (!isset($source['Software'])) ? false : trim($source['Software']),
286-
Exif::SOURCE => (!isset($source[self::SECTION_IPTC]['source'])) ? false : $source[self::SECTION_IPTC]['source'],
287-
Exif::TITLE => (!isset($source[self::SECTION_IPTC]['title'])) ? false : $source[self::SECTION_IPTC]['title'],
296+
Exif::SOURCE => (!isset($source[self::SECTION_IPTC]['source'])) ?
297+
false : $source[self::SECTION_IPTC]['source'],
298+
Exif::TITLE => (!isset($source[self::SECTION_IPTC]['title'])) ?
299+
false : $source[self::SECTION_IPTC]['title'],
288300
Exif::VERTICAL_RESOLUTION => $vertResolution,
289-
Exif::WIDTH => (!isset($source[self::SECTION_COMPUTED]['Width'])) ? false : $source[self::SECTION_COMPUTED]['Width'],
301+
Exif::WIDTH => (!isset($source[self::SECTION_COMPUTED]['Width'])) ?
302+
false : $source[self::SECTION_COMPUTED]['Width'],
290303
);
291304

292305
$arrMapping = array(

0 commit comments

Comments
 (0)