Skip to content

Commit 76a15ec

Browse files
committed
Fix phpstan errors level 1
1 parent 784de4b commit 76a15ec

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/BarcodeGeneratorPNG.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getBarcode(string $barcode, $type, int $widthFactor = 2, int $he
7676
$barHeight = round(($bar->getHeight() * $height / $barcodeData->getHeight()), 3);
7777

7878
// draw a vertical bar
79-
if ($this->useImagick && isset($imagickBarsShape)) {
79+
if ($this->useImagick) {
8080
$imagickBarsShape->rectangle($positionHorizontal, $y, ($positionHorizontal + $barWidth - 1), ($y + $barHeight));
8181
} else {
8282
imagefilledrectangle($image, $positionHorizontal, $y, ($positionHorizontal + $barWidth - 1), ($y + $barHeight), $gdForegroundColor);
@@ -85,7 +85,7 @@ public function getBarcode(string $barcode, $type, int $widthFactor = 2, int $he
8585
$positionHorizontal += $barWidth;
8686
}
8787

88-
if ($this->useImagick && isset($imagickBarsShape)) {
88+
if ($this->useImagick) {
8989
$image = $this->createImagickImageObject($width, $height);
9090
$image->drawImage($imagickBarsShape);
9191
return $image->getImageBlob();

src/Types/TypeCode128.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Picqer\Barcode\Barcode;
66
use Picqer\Barcode\BarcodeBar;
7+
use Picqer\Barcode\Exceptions\BarcodeException;
78
use Picqer\Barcode\Exceptions\InvalidCharacterException;
89
use Picqer\Barcode\Exceptions\InvalidLengthException;
910

@@ -331,11 +332,18 @@ public function getBarcodeData(string $code): Barcode
331332
$code_data[] = intval($chrnum);
332333
}
333334
break;
335+
336+
default:
337+
throw new InvalidCharacterException('Do not support different mode then A, B or C.');
334338
}
335339
}
336340
}
337341

338342
// calculate check character
343+
if (! isset($startid)) {
344+
throw new BarcodeException('Could not determine start char for barcode.');
345+
}
346+
339347
$sum = $startid;
340348
foreach ($code_data as $key => $val) {
341349
$sum += ($val * ($key + 1));

src/Types/TypePharmacodeTwoCode.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
use Picqer\Barcode\Barcode;
1111
use Picqer\Barcode\BarcodeBar;
12+
use Picqer\Barcode\Exceptions\BarcodeException;
13+
use Picqer\Barcode\Exceptions\InvalidCharacterException;
1214
use Picqer\Barcode\Exceptions\InvalidLengthException;
1315

1416
class TypePharmacodeTwoCode implements TypeInterface
@@ -62,6 +64,9 @@ public function getBarcodeData(string $code): Barcode
6264
$p = 0;
6365
$h = 2;
6466
break;
67+
68+
default:
69+
throw new InvalidCharacterException('Could not find bar for char.');
6570
}
6671

6772
$barcode->addBar(new BarcodeBar(1, $h, 1, $p));

0 commit comments

Comments
 (0)