php-aidc /
label-printer
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * This file is part of PhpAidc LabelPrinter package. |
||
| 5 | * |
||
| 6 | * © Appwilio (https://appwilio.com) |
||
| 7 | * © JhaoDa (https://github.com/jhaoda) |
||
| 8 | * |
||
| 9 | * For the full copyright and license information, please view the LICENSE |
||
| 10 | * file that was distributed with this source code. |
||
| 11 | */ |
||
| 12 | |||
| 13 | declare(strict_types=1); |
||
| 14 | |||
| 15 | namespace PhpAidc\LabelPrinter\Language\Fingerprint\Concerns; |
||
| 16 | |||
| 17 | use PhpAidc\LabelPrinter\Enum\Anchor; |
||
| 18 | use PhpAidc\LabelPrinter\Contract\Command; |
||
| 19 | use PhpAidc\LabelPrinter\Language\Fingerprint; |
||
| 20 | use PhpAidc\LabelPrinter\Command\Concerns\Alignable; |
||
| 21 | |||
| 22 | trait Align |
||
| 23 | { |
||
| 24 | public function align(Command $command) |
||
| 25 | { |
||
| 26 | /** @var Command|Alignable $command */ |
||
| 27 | if ($command->getAnchor() && !$command->getAnchor()->equals(Anchor::SOUTHWEST())) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 28 | $anchor = $command->getAnchor()->getValue(); |
||
| 29 | |||
| 30 | $newAnchor = $anchor + 6; |
||
| 31 | |||
| 32 | if ($newAnchor > 9) { |
||
| 33 | $newAnchor = $anchor > 6 ? $anchor - 6 : $anchor; |
||
| 34 | } |
||
| 35 | |||
| 36 | yield "AN {$newAnchor}"; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | public function resetAlign(Command $command) |
||
| 41 | { |
||
| 42 | /** @var Command|Alignable $command */ |
||
| 43 | if ($command->getAnchor() && !$command->getAnchor()->equals(Anchor::SOUTHWEST())) { |
||
| 44 | yield 'AN '.Fingerprint::DEFAULT_ANCHOR; |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 |