-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathTsplQRCode.php
41 lines (33 loc) · 1021 Bytes
/
TsplQRCode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* This file is part of PhpAidc LabelPrinter package.
*
* © Appwilio (https://appwilio.com)
* © JhaoDa (https://github.com/jhaoda)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace PhpAidc\LabelPrinter\Language\Tspl;
use PhpAidc\LabelPrinter\Command\QRCode;
final class TsplQRCode
{
public function translate(QRCode $command): iterable
{
$instruction = \vsprintf('QRCODE %d,%d,%s,%d,%s', [
$command->getX(),
$command->getY(),
$command->getECCLevel(),
$command->getCellWidth(),
$command->getMode()
]);
// rotation
$instruction .= ','.$command->getRotation()->getDegrees();
// model
if ($command->getModel()) {
$instruction .= ','.(string) $command->getModel();
}
yield $instruction.\sprintf(',"%s"', $command->getData());
}
}