Skip to content

Commit 266c5e3

Browse files
authored
Merge pull request #57 from Miljar/Miljar-patch-1
No exif, no exception
2 parents f411c27 + d59a151 commit 266c5e3

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

lib/PHPExif/Adapter/Native.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ public function getSectionsAsArrays()
170170
* Reads & parses the EXIF data from given file
171171
*
172172
* @param string $file
173-
* @return \PHPExif\Exif Instance of Exif object with data
174-
* @throws \RuntimeException If the EXIF data could not be read
173+
* @return \PHPExif\Exif|boolean Instance of Exif object with data
175174
*/
176175
public function getExifFromFile($file)
177176
{
@@ -187,9 +186,7 @@ public function getExifFromFile($file)
187186
);
188187

189188
if (false === $data) {
190-
throw new \RuntimeException(
191-
sprintf('Could not read EXIF data from file %1$s', $file)
192-
);
189+
return false;
193190
}
194191

195192
$xmpData = $this->getIptcData($file);

tests/PHPExif/Adapter/NativeTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ public function testAddRequiredSection()
103103
/**
104104
* @group native
105105
* @covers \PHPExif\Adapter\Native::getExifFromFile
106-
* @expectedException RuntimeException
107106
*/
108107
public function testGetExifFromFileNoData()
109108
{
110109
$file = PHPEXIF_TEST_ROOT . '/files/empty.jpg';
111-
$this->adapter->getExifFromFile($file);
110+
$result = $this->adapter->getExifFromFile($file);
111+
$this->assertFalse($result);
112112
}
113113

114114
/**

tests/PHPExif/ExifTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public function testAdapterConsistency()
624624
// find all Getter methods on the results and compare its output
625625
foreach ($methods as $method) {
626626
$name = $method->getName();
627-
if (strpos($name, 'get') !== 0 || $name == 'getRawData' || $name == 'getData') {
627+
if (strpos($name, 'get') !== 0 || $name == 'getRawData' || $name == 'getData' || $name == 'getColorSpace') {
628628
continue;
629629
}
630630
$this->assertEquals(

0 commit comments

Comments
 (0)