check digit
v3.0.1
https://www.gs1.org/services/how-calculate-check-digit-manually에서 숫자 공식 기반을 확인하고 https://www.gs1.org/services/check-digit-calculator에서 테스트했습니다.
작곡가를 통해 패키지를 설치할 수 있습니다.
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
최근 변경된 사항에 대한 자세한 내용은 변경 로그를 참조하세요.
자세한 내용은 CONTRIBUTING을 참조하세요.
보안 관련 문제를 발견한 경우 문제 추적기를 사용하는 대신 [email protected]으로 이메일을 보내주세요.
MIT 라이센스(MIT). 자세한 내용은 라이센스 파일을 참조하십시오.