From 42b64addfbefa30b8313561573a46997ff63cda6 Mon Sep 17 00:00:00 2001 From: Gawain Lynch Date: Sun, 4 Jun 2017 18:03:24 +0200 Subject: [PATCH] Use Info::isValid() to verify src and/or error images instead of catch() --- src/Creator.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Creator.php b/src/Creator.php index 51c9214..da2f0e9 100644 --- a/src/Creator.php +++ b/src/Creator.php @@ -63,23 +63,18 @@ public function create(Transaction $transaction) */ protected function verifyInfo(Transaction $transaction) { - try { - $transaction->getSrcImage()->getInfo(); - + if ($transaction->getSrcImage()->getInfo()->isValid()) { return; - } catch (IOException $e) { } - $transaction->setSrcImage($transaction->getErrorImage()); - try { - $transaction->getSrcImage()->getInfo(); - } catch (IOException $e) { - throw new RuntimeException( - 'There was an error with the thumbnail image requested and additionally the fallback image could not be displayed.', - 1, - $e - ); + if ($transaction->getSrcImage()->getInfo()->isValid()) { + return; } + + throw new RuntimeException( + 'There was an error with the thumbnail image requested and additionally the fallback image could not be displayed.', + 1 + ); } /**