allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
25
vendor/ageekdev/laravel-barcode/src/Helpers/BarcodeHelper.php
vendored
Normal file
25
vendor/ageekdev/laravel-barcode/src/Helpers/BarcodeHelper.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace AgeekDev\Barcode\Helpers;
|
||||
|
||||
class BarcodeHelper
|
||||
{
|
||||
public static function getChecksum(string $code): int
|
||||
{
|
||||
$len = strlen($code);
|
||||
$sum = 0;
|
||||
for ($i = 0; $i < $len; $i += 2) {
|
||||
$sum .= $code[$i];
|
||||
}
|
||||
$sum *= 3;
|
||||
for ($i = 1; $i < $len; $i += 2) {
|
||||
$sum .= ($code[$i]);
|
||||
}
|
||||
$r = $sum % 10;
|
||||
if ($r > 0) {
|
||||
$r = (10 - $r);
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
40
vendor/ageekdev/laravel-barcode/src/Helpers/BinarySequenceConverter.php
vendored
Normal file
40
vendor/ageekdev/laravel-barcode/src/Helpers/BinarySequenceConverter.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace AgeekDev\Barcode\Helpers;
|
||||
|
||||
use AgeekDev\Barcode\Barcode;
|
||||
use AgeekDev\Barcode\BarcodeBar;
|
||||
|
||||
/**
|
||||
* Convert binary barcode sequence string to Barcode representation.
|
||||
*/
|
||||
class BinarySequenceConverter
|
||||
{
|
||||
public static function convert(string $code, string $sequence): Barcode
|
||||
{
|
||||
$barcode = new Barcode($code);
|
||||
|
||||
return self::generate($sequence, $barcode);
|
||||
}
|
||||
|
||||
public static function generate(string $sequence, Barcode $barcode): Barcode
|
||||
{
|
||||
$len = strlen($sequence);
|
||||
$barWidth = 0;
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$barWidth++;
|
||||
if (($i === ($len - 1)) || (($i < ($len - 1)) && ($sequence[$i] !== $sequence[($i + 1)]))) {
|
||||
if ($sequence[$i] === '1') {
|
||||
$drawBar = true;
|
||||
} else {
|
||||
$drawBar = false;
|
||||
}
|
||||
|
||||
$barcode->addBar(new BarcodeBar($barWidth, 1, $drawBar));
|
||||
$barWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $barcode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user