| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Endroid\QrCode\Writer\Result; |
| 6 |
|
| 7 |
use Endroid\QrCode\Matrix\MatrixInterface; |
| 8 |
|
| 9 |
final class PngResult extends GdResult |
| 10 |
{ |
| 11 |
public function __construct( |
| 12 |
MatrixInterface $matrix, |
| 13 |
\GdImage $image, |
| 14 |
private readonly int $quality = -1 |
| 15 |
) { |
| 16 |
parent::__construct($matrix, $image); |
| 17 |
} |
| 18 |
|
| 19 |
public function getString(): string |
| 20 |
{ |
| 21 |
ob_start(); |
| 22 |
imagepng($this->image, quality: $this->quality); |
| 23 |
|
| 24 |
return strval(ob_get_clean()); |
| 25 |
} |
| 26 |
|
| 27 |
public function getMimeType(): string |
| 28 |
{ |
| 29 |
return 'image/png'; |
| 30 |
} |
| 31 |
} |