| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Endroid\QrCode\Writer\Result; |
| 6 |
|
| 7 |
use Endroid\QrCode\Matrix\MatrixInterface; |
| 8 |
|
| 9 |
abstract class AbstractResult implements ResultInterface |
| 10 |
{ |
| 11 |
public function __construct( |
| 12 |
private readonly MatrixInterface $matrix |
| 13 |
) { |
| 14 |
} |
| 15 |
|
| 16 |
public function getMatrix(): MatrixInterface |
| 17 |
{ |
| 18 |
return $this->matrix; |
| 19 |
} |
| 20 |
|
| 21 |
public function getDataUri(): string |
| 22 |
{ |
| 23 |
return 'data:'.$this->getMimeType().';base64,'.base64_encode($this->getString()); |
| 24 |
} |
| 25 |
|
| 26 |
public function saveToFile(string $path): void |
| 27 |
{ |
| 28 |
$string = $this->getString(); |
| 29 |
file_put_contents($path, $string); |
| 30 |
} |
| 31 |
} |