Skip to content

Commit 8102273

Browse files
committed
fix: check for gd function existence
1 parent 348745f commit 8102273

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Exception/BlockSizeTooSmallException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
final class BlockSizeTooSmallException extends \Exception
88
{
9-
}
9+
}

src/ImageData/LogoImageData.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
use Endroid\QrCode\Logo\LogoInterface;
88

9-
final class LogoImageData
9+
final readonly class LogoImageData
1010
{
1111
private function __construct(
12-
private readonly string $data,
12+
private string $data,
1313
private ?\GdImage $image,
14-
private readonly string $mimeType,
15-
private readonly int $width,
16-
private readonly int $height,
17-
private readonly bool $punchoutBackground,
14+
private string $mimeType,
15+
private int $width,
16+
private int $height,
17+
private bool $punchoutBackground,
1818
) {
1919
}
2020

@@ -45,6 +45,10 @@ public static function createForLogo(LogoInterface $logo): self
4545
return new self($data, null, $mimeType, $width, $height, $logo->getPunchoutBackground());
4646
}
4747

48+
if (!function_exists('imagecreatefromstring')) {
49+
throw new \Exception('Function "imagecreatefromstring" does not exist: check your GD installation');
50+
}
51+
4852
error_clear_last();
4953
$image = @imagecreatefromstring($data);
5054

0 commit comments

Comments
 (0)