check digit
v3.0.1
Periksa rumus digit berdasarkan https://www.gs1.org/services/how-calculate-check-digit-manually, dan diuji oleh https://www.gs1.org/services/check-digit-calculator
Anda dapat menginstal paket melalui composer:
composer require lloricode/check-digit
// Sample usage in testing
// tests/Feature/GenerateTest.php
use Lloricode CheckDigit Enums Format ;
use Lloricode CheckDigit Generator ;
# base in https://www.gs1.org/services/check-digit-calculator
assertSame ( 2 , Generator :: new ( 9638527 , Format :: GTIN_8 ())-> getCheckDigit ());
assertSame ( 4 , Generator :: new ( 3216549 , Format :: GTIN_8 ())-> getCheckDigit ());
assertSame ( 2 , Generator :: new ( 91739456321 , Format :: GTIN_12 ())-> getCheckDigit ());
assertSame ( 8 , Generator :: new ( 74185245963 , Format :: GTIN_12 ())-> getCheckDigit ());
assertSame ( 3 , Generator :: new ( 629104150021 , Format :: GTIN_13 ())-> getCheckDigit ());
assertSame ( 6 , Generator :: new ( 123456789876 , Format :: GTIN_13 ())-> getCheckDigit ());
assertSame ( 6 , Generator :: new ( 7539514528423 , Format :: GTIN_14 ())-> getCheckDigit ());
assertSame ( 5 , Generator :: new ( 8563251459762 , Format :: GTIN_14 ())-> getCheckDigit ());
assertSame ( 0 , Generator :: new ( 7896541230123456 , Format :: GSIN ())-> getCheckDigit ());
assertSame ( 3 , Generator :: new ( 7658485040650456 , Format :: GSIN ())-> getCheckDigit ());
assertSame ( 6 , Generator :: new ( 95135623050123698 , Format :: SSCC ())-> getCheckDigit ());
assertSame ( 7 , Generator :: new ( 87643802105978513 , Format :: SSCC ())-> getCheckDigit ());
// get generated value
assertSame ( ' 876438021059785137 ' , Generator :: new ( 87643802105978513 , Format :: SSCC ())-> getValue ());
// starts with zero
assertSame ( 7 , Generator :: new ( ' 0012345 ' , Format :: GTIN_8 ())-> getCheckDigit ());
assertSame ( 5 , Generator :: new ( ' 00123456789 ' , Format :: GTIN_12 ())-> getCheckDigit ());
assertSame ( 5 , Generator :: new ( ' 001234567890 ' , Format :: GTIN_13 ())-> getCheckDigit ());
assertSame ( 2 , Generator :: new ( ' 0012345678901 ' , Format :: GTIN_14 ())-> getCheckDigit ());
assertSame ( 3 , Generator :: new ( ' 0012345678901234 ' , Format :: GSIN ())-> getCheckDigit ());
assertSame ( 2 , Generator :: new ( ' 00123456789012345 ' , Format :: SSCC ())-> getCheckDigit ());
vendor/bin/pest
Silakan lihat CHANGELOG untuk informasi lebih lanjut tentang apa yang berubah baru-baru ini.
Silakan lihat KONTRIBUSI untuk rinciannya.
Jika Anda menemukan masalah terkait keamanan, silakan kirim email ke [email protected] alih-alih menggunakan pelacak masalah.
Lisensi MIT (MIT). Silakan lihat File Lisensi untuk informasi lebih lanjut.