Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| QrCodePdfPreviewService | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| render | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| standardPaper | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Shared\Services; |
| 4 | |
| 5 | use Barryvdh\DomPDF\Facade\Pdf; |
| 6 | |
| 7 | class QrCodePdfPreviewService |
| 8 | { |
| 9 | /** |
| 10 | * @param array<int, array<string, mixed>> $labels |
| 11 | */ |
| 12 | public function render(array $labels, string $size): string |
| 13 | { |
| 14 | return Pdf::loadView('components.pdfs.qrcodes.qrcode-preview', [ |
| 15 | 'labels' => $labels, |
| 16 | 'size' => $size, |
| 17 | ]) |
| 18 | ->setPaper($this->standardPaper(), 'portrait') |
| 19 | ->output(); |
| 20 | } |
| 21 | |
| 22 | private function standardPaper(): array |
| 23 | { |
| 24 | [$widthMm, $heightMm] = [100, 70]; |
| 25 | $mmToPoints = 2.83465; |
| 26 | |
| 27 | return [0, 0, $widthMm * $mmToPoints, $heightMm * $mmToPoints]; |
| 28 | } |
| 29 | } |