Skip to content

Commit

Permalink
Merge pull request #49 from OskarStark/exception
Browse files Browse the repository at this point in the history
throw exception instead of returning false
  • Loading branch information
casperbakker authored Sep 28, 2017
2 parents 7d90abc + 6bccdc4 commit f754cbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/BarcodeGeneratorJPG.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Picqer\Barcode;

use Picqer\Barcode\Exceptions\BarcodeException;

class BarcodeGeneratorJPG extends BarcodeGenerator
{

Expand All @@ -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))
{
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/BarcodeGeneratorPNG.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Picqer\Barcode;

use Picqer\Barcode\Exceptions\BarcodeException;

class BarcodeGeneratorPNG extends BarcodeGenerator
{

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f754cbd

Please sign in to comment.