Created
January 8, 2014 14:41
-
-
Save J7mbo/8317804 to your computer and use it in GitHub Desktop.
Why no indented ifs?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@inheritdoc} | |
* | |
* @note Image dimensions returned as array(width, height) | |
*/ | |
public function fetchMetaDataFrom($filePath) | |
{ | |
if (file_exists($filePath)) | |
{ | |
if ($metadata = @getimagesize($filePath) !== false) | |
{ | |
list($width, $height, $type, /** Skip $attr **/) = $metadata; | |
$extension = $this->resolveImageType($type); | |
if (in_array($extension, $this->allowedImageTypes)) | |
{ | |
return array($width, $height); | |
} | |
else | |
{ | |
throw new MetaDataImageExtensionNotAllowedException(sprintf("File %s wasn't in allowed image types: %s", $extension, print_r($this->allowedImageTypes, true))); | |
} | |
} | |
else | |
{ | |
throw new MetaDataFileNotReadableException(sprintf("File %s metadata couldn't be read. Permissions problem?", $filePath)); | |
} | |
} | |
else | |
{ | |
throw new MetaDataFileNotFoundException(sprintf("File %s could not be found for metadata retrieval", $filePath)); | |
} | |
} |
rdlowrey
commented
Jan 8, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment