Skip to content

Commit

Permalink
Improve invalid font path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Apr 3, 2019
1 parent 9cc1eae commit 666a9c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/QrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ public function getLabelFontSize(): ?int

public function setLabelFontPath(string $labelFontPath): void
{
$labelFontPath = realpath($labelFontPath);
$resolvedLabelFontPath = realpath($labelFontPath);

if (!is_file($labelFontPath)) {
if (!is_string($resolvedLabelFontPath) || !is_file($resolvedLabelFontPath)) {
throw new InvalidPathException('Invalid label font path: '.$labelFontPath);
}

$this->labelFontPath = $labelFontPath;
$this->labelFontPath = $resolvedLabelFontPath;
}

public function getLabelFontPath(): ?string
Expand Down
2 changes: 1 addition & 1 deletion tests/QrCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function testSetLabel(): void
{
$qrCode = new QrCode('QR Code');
$qrCode->setSize(300);
$qrCode->setLabel('Scan the code', 15);
$qrCode->setLabel('Scan the code', 15, 'test');

$pngData = $qrCode->writeString();
$this->assertTrue(is_string($pngData));
Expand Down

0 comments on commit 666a9c9

Please sign in to comment.