Skip to content

Commit

Permalink
Fix types and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Nov 26, 2018
1 parent 5f03443 commit 4752fc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Writer/SvgWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ private function addLogo(SimpleXMLElement $svg, int $imageWidth, int $imageHeigh
}

$imageDefinition = $svg->addChild('image');
$imageDefinition->addAttribute('x', $imageWidth / 2 - $logoWidth / 2);
$imageDefinition->addAttribute('y', $imageHeight / 2 - $logoHeight / 2);
$imageDefinition->addAttribute('width', $logoWidth);
$imageDefinition->addAttribute('height', $logoHeight);
$imageDefinition->addAttribute('x', strval($imageWidth / 2 - $logoWidth / 2));
$imageDefinition->addAttribute('y', strval($imageHeight / 2 - $logoHeight / 2));
$imageDefinition->addAttribute('width', strval($logoWidth));
$imageDefinition->addAttribute('height', strval($logoHeight));
$imageDefinition->addAttribute('preserveAspectRatio', 'none');
$imageDefinition->addAttribute('xlink:href', 'data:'.$mimeType.';base64,'.base64_encode($imageData));
}
Expand Down
2 changes: 2 additions & 0 deletions tests/QrCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function testFactory(): void
public function testWriteQrCode(): void
{
$qrCode = new QrCode('QR Code');
$qrCode->setLogoPath(__DIR__.'/../assets/images/symfony.png');
$qrCode->setLogoWidth(100);

$qrCode->setWriterByName('binary');
$binData = $qrCode->writeString();
Expand Down

0 comments on commit 4752fc7

Please sign in to comment.