| Conditions | 2 |
| Paths | 2 |
| Total Lines | 27 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | public function translate(Barcode $command): iterable |
||
| 22 | { |
||
| 23 | $instruction = \vsprintf('BARCODE %d,%d,"%s",%d', [ |
||
| 24 | $command->getX(), |
||
| 25 | $command->getY(), |
||
| 26 | $command->getType(), |
||
| 27 | $command->getHeight(), |
||
| 28 | ]); |
||
| 29 | |||
| 30 | // human readable |
||
| 31 | $instruction .= ','.(int) $command->isReadable(); |
||
| 32 | |||
| 33 | // rotation |
||
| 34 | $instruction .= ','.$command->getRotation()->getDegrees(); |
||
| 35 | |||
| 36 | // width of narrow element |
||
| 37 | $instruction .= ','.(int) $command->getRatio()['narrow']; |
||
| 38 | |||
| 39 | // width of wide element |
||
| 40 | $instruction .= ','.(int) $command->getRatio()['wide']; |
||
| 41 | |||
| 42 | // alingment (Rongta RP 4xx/Atol BP4x doesn't support alignment and prints void) |
||
| 43 | if ($command->getAnchor()) { |
||
| 44 | $instruction .= ','.$command->getAnchor()->getValue(); |
||
| 45 | } |
||
| 46 | |||
| 47 | yield $instruction.\sprintf(',"%s"', $command->getData()); |
||
| 48 | } |
||
| 50 |