Skip to content

Commit

Permalink
Make sure any __toString modification meets the requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Mar 26, 2014
1 parent 2f3150f commit 3d6b85f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Tmdb/Model/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,20 @@ public function getWidth()
/**
* Return the file path when casted to string
*
* @throws \Exception when the filepath is empty.
* @return mixed
*/
public function __toString()
{
$filePath = $this->getFilePath();

if (empty($filePath)) {
throw new \Exception(sprintf(
'Trying to convert an instance of "%s" into an string, but there was no filePath found.',
get_class($this)
));
}

return $this->getFilePath();
}
}

0 comments on commit 3d6b85f

Please sign in to comment.