diff --git a/src/BarcodeGeneratorJPG.php b/src/BarcodeGeneratorJPG.php index 694b1fa..b1cb72c 100644 --- a/src/BarcodeGeneratorJPG.php +++ b/src/BarcodeGeneratorJPG.php @@ -2,6 +2,8 @@ namespace Picqer\Barcode; +use Picqer\Barcode\Exceptions\BarcodeException; + class BarcodeGeneratorJPG extends BarcodeGenerator { @@ -15,6 +17,7 @@ class BarcodeGeneratorJPG extends BarcodeGenerator * @param array $color RGB (0-255) foreground color for bar elements (background is transparent). * @return string image data or false in case of error. * @public + * @throws BarcodeException */ public function getBarcode($code, $type, $widthFactor = 2, $totalHeight = 30, $color = array(0, 0, 0)) { @@ -39,7 +42,7 @@ public function getBarcode($code, $type, $widthFactor = 2, $totalHeight = 30, $c $imageMagickObject = new \imagickdraw(); $imageMagickObject->setFillColor($colorForeground); } else { - return false; + throw new BarcodeException('Neither gd-lib or imagick are installed!'); } // print bars diff --git a/src/BarcodeGeneratorPNG.php b/src/BarcodeGeneratorPNG.php index 4a67ee4..f788392 100644 --- a/src/BarcodeGeneratorPNG.php +++ b/src/BarcodeGeneratorPNG.php @@ -2,6 +2,8 @@ namespace Picqer\Barcode; +use Picqer\Barcode\Exceptions\BarcodeException; + class BarcodeGeneratorPNG extends BarcodeGenerator { @@ -39,7 +41,7 @@ public function getBarcode($code, $type, $widthFactor = 2, $totalHeight = 30, $c $imageMagickObject = new \imagickdraw(); $imageMagickObject->setFillColor($colorForeground); } else { - return false; + throw new BarcodeException('Neither gd-lib or imagick are installed!'); } // print bars