PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.7
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.7
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
woocommerce-pos / vendor_prefixed / picqer / php-barcode-generator / src / Helpers / BinarySequenceConverter.php

BinarySequenceConverter.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.7, at vendor_prefixed/picqer/php-barcode-generator/src/Helpers/BinarySequenceConverter.php

32 lines 912 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WCPOS\Vendor\Picqer\Barcode\Helpers;
4
5 use WCPOS\Vendor\Picqer\Barcode\Barcode;
6 use WCPOS\Vendor\Picqer\Barcode\BarcodeBar;
7 /**
8 * Convert binary barcode sequence string to Barcode representation.
9 */
10 class BinarySequenceConverter
11 {
12 public static function convert(string $code, string $sequence) : Barcode
13 {
14 $barcode = new Barcode($code);
15 $len = \strlen($sequence);
16 $barWidth = 0;
17 for ($i = 0; $i < $len; ++$i) {
18 $barWidth += 1;
19 if ($i == $len - 1 || $i < $len - 1 && $sequence[$i] != $sequence[$i + 1]) {
20 if ($sequence[$i] == '1') {
21 $drawBar = \true;
22 } else {
23 $drawBar = \false;
24 }
25 $barcode->addBar(new BarcodeBar($barWidth, 1, $drawBar));
26 $barWidth = 0;
27 }
28 }
29 return $barcode;
30 }
31 }
32